import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-3,3,50)
y = 0.1*x
plt.figure()
#范围
plt.xlim((-4,4))
plt.ylim((-5,5))
plt.xlabel('X')
plt.ylabel('Y')
ax = plt.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.spines['bottom'].set_position(('data',0))
ax.yaxis.set_ticks_position('left')
ax.spines['left'].set_position(('data',0))
new_ticks = np.linspace(-5,5,10)
plt.xticks(new_ticks)
plt.yticks(new_ticks)
#能见度
plt.plot(x,y)
for label in ax.get_xticklabels()+ax.get_yticklabels():
label.set_fontsize(12)
label.set_bbox(dict(facecolor='white',edgecolor='None',alpha=0.7))
plt.show()
标签:plt,能见度,ticks,spines,set,position,ax,07tick
From: https://www.cnblogs.com/lyc2001/p/17080710.html