Reputation: 751
I have a plt.figure(...) with several subplots, my code looks essentially like this:
num_plots = 2
my_dpi = 96
fig_size = (1440 / my_dpi, 900 / my_dpi)
fig = plt.figure(figsize=fig_size, dpi=my_dpi, frameon=False)
# Subplot 1
fig.add_subplot(num_plots, 1, 1)
# plot fancy stuff
# Subplot 2
fig.add_subplot(num_plots, 1, 2)
# plot fancy stuff
What I would love to have is something like
fig.get_all_subplots.xtick(size='small')
Thank you for your support!
EDIT:
I think it should rather be something like plt.get_all_subplots instead of fig.get_all_subplots
Upvotes: 4
Views: 28914
Reputation: 25362
There a two things you can do here. If you want to change the tick size for all figures in the script you are running, you need to add the following at the top of your code:
import matplotlib
matplotlib.rc('xtick', labelsize=20)
matplotlib.rc('ytick', labelsize=20)
This will be sufficient for your current code as there is only one plot. However if you were to have more than one plot but only wanted to change the size of the ticks for a specific figure, then you could use plt.tick_params
, for example:
import matplotlib.pyplot as plt
fig,ax = plt.subplots()
plt.plot(x,y)
plt.xlabel('Time')
plt.ylabel('Temperature')
plt.tick_params(axis='both', which='major', labelsize=22)
Upvotes: 7