1

我的 pyplot 图表需要 loglog 的“相反”。我怎样才能达到指数轴?

数据如下:

x = [1, 2, 4]
y = [1, 2, 4]
z = [2, 2, 2]

quadranten = plt.figure()
s = [20*4**n for n in z]    

fig, ax = plt.subplots()
ax.axis([1, 5, 1, 5])
ax.loglog() <-- opposite function?

xstart, xend = ax.get_xlim()
ax.xaxis.set_ticks(np.arange(xstart, xend, 0.712123))
ax.xaxis.set_major_formatter(ticker.FormatStrFormatter('%0.1f'))

ystart, yend = ax.get_ylim()
ax.yaxis.set_ticks(np.arange(ystart, yend, 0.712123))
ax.yaxis.set_major_formatter(ticker.FormatStrFormatter('%0.1f'))

plt.xlabel('x')
plt.ylabel('y')

plt.scatter(x,y,s=s)
plt.show()

目标是 x 轴具有均匀大小的步长:0, 1, 2, 4, 8... 2, 4, 8, ...

这可能吗?

像这样的东西: 指数的

4

1 回答 1

0

loglog接受参数basexbasey控制对数的底:

loglog(arange(1,100), arange(1,100)**2, basex=2, basey=2)

在此处输入图像描述

于 2018-07-04T06:35:22.010 回答