Fal*_*rri 9 python matplotlib scipy
如何控制pyplot图的轴设置.我完成了
pylab.plot(*self.plot_generator(low, high))
pylab.show()
Run Code Online (Sandbox Code Playgroud)
我得到的就是我想要的东西
但我希望x轴为0而不是底部.我该怎么办?
dou*_*oug 18
# create some data
x = np.linspace(-np.pi,np.pi,100)
y = np.cos(2.5*x)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x,y, mfc='orange', mec='orange', marker='.')
# using 'spines', new in Matplotlib 1.0
ax.spines['left'].set_position('zero')
ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position('zero')
ax.spines['top'].set_color('none')
ax.spines['left'].set_smart_bounds(True)
ax.spines['bottom'].set_smart_bounds(True)
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
ax.axhline(linewidth=2, color='blue')
ax.axvline(linewidth=2, color='blue')
show()
Run Code Online (Sandbox Code Playgroud)
ami*_*des 11
要将x轴的起点设置为0:
pylab.xlim(xmin=0)
Run Code Online (Sandbox Code Playgroud)
要将y轴的起点设置为0:
pylab.ylim(ymin=0)
Run Code Online (Sandbox Code Playgroud)
在pylab.plot
通话结束后,将其中一行(或两者,如果您愿意)放入其中.
归档时间: |
|
查看次数: |
27474 次 |
最近记录: |