Can we apply tick marks in Matplotlib without creating an Axes?
If you have more than one axes, you should usually apply ticks directly to each axes. However, if you only have one plot, then you do not have to create and apply to an axes, but instead just apply to the entire plot area directly.
Many of the functions you apply to axes like
set_xticks have an equivalent when applying to the entire plot. Usually, their equivalents require just adding
set_ for the beginning of the method for axes.
# Equivalent methods for plot and axes plt.xticks() ax.set_xticks() plt.xticklabels() ax.set_xticklabels() plt.xlabel() ax.set_xlabel()