These crawls are part of an effort to archive pages as they are created and archive the pages that they refer to. That way, as the pages that are referenced are changed or taken from the web, a link to the version that was live when the page was written will be preserved.
Then the Internet Archive hopes that references to these archived pages will be put in place of a link that would be otherwise be broken, or a companion link to allow people to see what was originally intended by a page's authors.
This is a collection of pages and embedded objects from WordPress blogs and the external pages they link to. Captures of these pages are made on a continuous basis seeded from a feed of new or changed pages hosted by Wordpress.com or by Wordpress pages hosted by sites running a properly configured Jetpack wordpress plugin.
TIMESTAMPS
The Wayback Machine - https://web.archive.org/web/20230115013623/https://github.com/matplotlib/matplotlib/issues/12318
Unlike plt.xticks or plt.yticks, ax.set_xticks and ax.set_yticks has no argument fontsize.
To change the fontsize of ticklabels in a subplot, the shortest workaround (to my knowledge) is:
fortickinax.xaxis.get_majorticklabels(): # example for xaxistick.set_fontsize(12)
This feels too convoluted. It should not be more complicated than ax.set_xticks(fontsize=12)
Code for reproduction
fig, ax=plt.subplots(1, 2, figsize=(10, 4))
ax[0].plot(range(10), [x**2forxinrange(10)]) # First subplotax[0].set_xticks(fontsize=10) # where I want fontsize 10 on xticks ax[1].plot(range(10), [x**3forxinrange(10)]) # Second subplotax[1].set_xticks(fontsize=12) # where I want fontsize 12 on xticksplt.show()
Actual outcome
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-561-19741a4fe5dc> in <module>()
2
3 ax[0].plot(range(10), [x**2 for x in range(10)]) # First subplot
----> 4 ax[0].set_xticks(fontsize=10) # where I want fontsize 10 on xticks
5
6 ax[1].plot(range(10), [x**3 for x in range(10)]) # Second subplot
TypeError: set_xticks() got an unexpected keyword argument 'fontsize'
First, set_xticks does not have fontsize argument because set_xticks sets the location of the ticks, not the labels to be shown. Those can be set via set_xticklabels, and indeed set_xticklabels does have a fontsize argument. However, it requires you to specify the ticklabels, which only makes sense when using a FixedLocator.
Usually you would neither set the tick positions nor the labels to any fixed numbers but use the default locator and formatter or use your own locators or formatters. In those cases the easiest way to set the fontsize is to use .tick_params
ax.tick_params(axis="x", labelsize=12)
It does not allow to set other font or text related parameters like font-weight or alignment though. This is indeed a missing bit in the API. A slightly less convenient way is to use pyplot here
which then allows to set all properties at once. The drawback is that it is kind of convoluted and requires pyplot.
In conclusion I think there is some need to change the way text properties can be set on axis labels, but set_xticks is surely not the right place to do that.
Bug report
Bug summary
Unlike
plt.xticks
orplt.yticks
,ax.set_xticks
andax.set_yticks
has no argumentfontsize
.To change the fontsize of ticklabels in a subplot, the shortest workaround (to my knowledge) is:
This feels too convoluted. It should not be more complicated than
ax.set_xticks(fontsize=12)
Code for reproduction
Actual outcome
Expected outcome
Matplotlib version
print(matplotlib.get_backend())
): module://ipykernel.pylab.backend_inlineThe text was updated successfully, but these errors were encountered: