[英]How to set different “step” on axis X in my figure in matplotlib python 2.7 or 3.5?
I have some code:我有一些代码:
import numpy as np
import matplotlib.pyplot as plt
x = [0,1,2,3,4,5,6]
y = [5,6,7,10,100,10000,1000000]
plt.plot(x,y)
plt.xticks(np.arange(min(x), max(x)+1, 1.0))
plt.show()
You see, the biggest value is 1000000, if one value is very big, the other small values seems zero from the chart.你看,最大值是 1000000,如果一个值很大,从图表上看,其他小的值似乎为零。
Can i use different steps for the axis Y?我可以对 Y 轴使用不同的步骤吗?
The axis Y like this: small step... middle step... big step... Y轴是这样的:小步...中步...大步...
You could use a logarithmic scale by setting plt.yscale()
:您可以通过设置
plt.yscale()
使用对数刻度:
import numpy as np
import matplotlib.pyplot as plt
plt.yscale('log')
x = [0,1,2,3,4,5,6]
y = [5,6,7,10,100,10000,1000000]
plt.plot(x,y)
plt.xticks(np.arange(min(x), max(x)+1, 1.0))
plt.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.