Matplotlib对数轴刻度

2024-04-30 01:26:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个简单的代码来绘制一些值:

ticks = [0, 1e-12, 1e-10, 1e-8, 1e-6, 1e-4]
values = range(1, 7)

plt.plot(ticks, values)
plt.xscale('log')

plt.show()

enter image description here

问题是点(0,1)没有绘制出来。我试图通过添加一行代码来解决这个问题:

^{pr2}$

但结果是:

enter image description here

这绝对不是我想要的。我的目标是正确绘制点(0,1)并在x轴上设置自定义刻度,即ticks(0,1e-12,1e-10,1e-8,1e-6,1e-4)中的值

我该怎么做?我环顾四周,没有找到答案


Tags: 答案代码log目标plotshow绘制range