import matplotlib.pyplot as plt
x1 =[0,5000,10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 55000];
y1=[0, 223, 488, 673, 870, 1027, 1193, 1407, 1609, 1791, 2113, 2388];
x2 =[0,5000,10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 55000];
y2=[0, 214, 445, 627, 800, 956, 1090, 1281, 1489, 1625, 1896, 2151];
figsize = 11,9
figure, ax = plt.subplots(figsize=figsize)
A,=plt.plot(x1,y1,'-r',label='A',linewidth=5.0)
B,=plt.plot(x2,y2,'b-.',label='B',linewidth=5.0)
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size' : 23,
}
legend = plt.legend(handles=[A,B],prop=font1)
plt.tick_params(labelsize=23)
labels = ax.get_xticklabels() + ax.get_yticklabels()
[label.set_fontname('Times New Roman') for label in labels]
font2 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size' : 30,
}
plt.xlabel('round',font2)
plt.ylabel('value',font2)
plt.savefig('figure.eps')
plt.show()
实例1:为二维子图设置坐标轴标题
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(2,2,1)
ax.set_xlabel('Month')
ax.set_ylabel('Year')
plt.show()
函数说明
matplotlib.axes.Axes.set_xlabel(xlabel, fontdict=None, labelpad=None, **kwargs)
实例2:为三维子图设置坐标轴标题
import matplotlib.pyplot as plt
fig = plt.figure()
from mpl_toolkits.mplot3d import Axes3D
ax = fig.add_subplot(212, projection='3d')
ax.set_xlabel('Month')
ax.set_ylabel('Year')
ax.set_zlabel('Sales')
plt.show()