What is the purpose of 'xticks' and 'yticks' in the pyplot?
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.
Related questions:
2025: 15 May Shift 2
2026: 29 May Shift 2
2025: 21 May Shift 1