import numpy as np
import matplotlib.pyplot as plt
plt.figure()
x = np.arange(0,10,1)
z = x**2
y = np.linspace(1,10,10)
plt.plot(x,z,color = 'red',linewidth=1.0,linestyle='--')
plt.title(u'方法一')
plt.xlabel('X')
plt.ylabel('Y')
plt.xlim(0,10)
plt.ylim(0,100)
plt.xticks([0,1,2,3,4,5,6,7,8,9,10])
plt.yticks([0, 20, 60, 80, 100],
[r'$really\ bad$', r'$bad$', r'$normal$', r'$good$', r'$readly\ good$'])
ax = plt.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax = plt.gca()
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
ax.spines['bottom'].set_position(('data', 10))
ax.spines['left'].set_position(('data', 2))
plt.show()
参考:
- python-----设置标题、轴标签、刻度标签(ticker部分)