hec*_*pal 13 python matplotlib
在使用Matplotlib进行绘图时,我发现了如何更改标签的字体大小.但是,如何更改比例中数字的大小?
为清楚起见,假设您将x ^ 2从(x0,y0)= 0,0绘制到(x1,y1)=(20,20).下面的x轴上的刻度可能是这样的
0 1 2 ... 20.
我想改变这种x轴刻度的字体大小.
Cor*_*hin 23
Matplotlib将这些称为xtick标签.它们可以以多种不同的方式进行更改,作为参数传递,或者迭代和编辑(如此处发布的解决方案Matplotlib使得刻度标签字体更小).
我继续发布了一个更简洁的解决方案,因为前者非常低效.
from matplotlib import pyplot
import math
def setLabelExample():
fig = pyplot.figure()
x = [i for i in range(200)]
y = [xi**2 for xi in x]
ax = fig.add_subplot(1,1,1)
ax.plot(x, y)
ax.tick_params(axis='x', labelsize=30)
fig.suptitle('Matplotlib xticklabels Example')
pyplot.show()
if __name__ == '__main__':
setLabelExample()
Run Code Online (Sandbox Code Playgroud)