Skip to main contentSkip to solution

What is the purpose of 'xticks' and 'yticks' in the pyplot?

Solution

✅ Correct Option: 1

In matplotlib, plt.xticks() and plt.yticks() get or set the tick locations (the positions on the axis) and the tick labels (the text shown at those positions). For example, plt.xticks([0, 1, 2], ['a', 'b', 'c']) places ticks at 0, 1 and 2 and labels them a, b and c.


Option 2: legends are controlled by plt.legend(), not by the tick functions.

Option 3: it is close, but the official description says tick locations, not tick marks.

Option 4: tick length is changed with tick_params(length=...), not with xticks or yticks.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question