I'm using the mathplot library from Python to illustrate some data, and in order to present it for a paper I'm looking to increase its readability by increasing the size of the axis labels and ticks.
However, I've only been able to modify only the size of the text for the legends, and no matter how much I change the value for the text size for the labels and ticks, they remain the same.
I've tried the following solutions I found on this website, but none seem to work (using the standard import mathplotlib.plytplot as plt):
#Attempt #1
params = {'axes.labelsize': 20,'axes.titlesize':20, 'legend.fontsize': 20, 'xtick.labelsize': 20, 'ytick.labelsize': 20}
plt.rcParams.update(params)
################################################
#Attempt #2
MEDIUM_SIZE = 16
BIGGER_SIZE = 12
font = {'family' : 'Arial','weight' : 'bold', 'size' : 22}
plt.rc('font', **font)
plt.rc('font', size=MEDIUM_SIZE) # controls default text sizes
plt.rc('axes', titlesize=MEDIUM_SIZE) # fontsize of the axes title
plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels
plt.rc('xtick', labelsize=MEDIUM_SIZE) # fontsize of the tick labels
plt.rc('ytick', labelsize=MEDIUM_SIZE) # fontsize of the tick labels
plt.rc('legend', fontsize=BIGGER_SIZE) # legend fontsize
plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title
################################################
#Attempt #3
plt.rcParams['axes.linewidth'] = 20.0
plt.rcParams['xtick.labelsize']=8
plt.rcParams['ytick.labelsize']=8
################################################
#Attempt #4
ax = plt.subplot(111, xlabel='x', ylabel='y', title='title')
for item in ([ax.title, ax.xaxis.label, ax.yaxis.label] +
ax.get_xticklabels() + ax.get_yticklabels()):
item.set_fontsize(20)
I expected the size of the labels and the ticks to change by modifying the corresponding parameters. However, they always stay the same.
The only text that actually changes is the one of the legends, so I find it weird it only affects this one.
I've already tried the solutions proposed here without any results:
How to change the font size on a matplotlib plot
Why doesn't the matplotlib label 'fontsize' work?
Python: How to increase/reduce the fontsize of x and y tick labels?
from Can't change label size of Python Mathplot
No comments:
Post a Comment