2024-04-20 10:30:33 发布
网友
我在下面做了一个对数比例图。你知道吗
如何在没有科学符号的情况下显示规则的记号?你知道吗
如何定制不同格式组合的刻度?你知道吗
plt.plot(np.arange(1000)) plt.xscale('log') plt.yscale('log') plt.ylim(1,10) plt.show()
因为你说你试过these solutions,但是没有成功,我怀疑是因为你在把scale设置为log之前调用了ax.yaxis.set_major_formatter。如果这样做,当你说plt.xscale('log')和plt.yscale('log')时,它会重置x和y轴。你知道吗
scale
log
ax.yaxis.set_major_formatter
plt.xscale('log')
plt.yscale('log')
如果你在后面叫它,它就工作了:
import matplotlib as mpl import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(1,1,1) plt.plot(np.arange(1000)) plt.xscale('log') plt.yscale('log') ax.yaxis.set_major_formatter(mpl.ticker.ScalarFormatter()) ax.xaxis.set_major_formatter(mpl.ticker.ScalarFormatter()) plt.show()
因为你说你试过these solutions,但是没有成功,我怀疑是因为你在把
scale
设置为log
之前调用了ax.yaxis.set_major_formatter
。如果这样做,当你说plt.xscale('log')
和plt.yscale('log')
时,它会重置x和y轴。你知道吗如果你在后面叫它,它就工作了:
相关问题 更多 >
编程相关推荐