如何在Python中使用“双对数”轴渲染散点图?

问题描述 投票:0回答:1

此情节来自维基百科,图例如下:

X 轴采用对数(log)刻度 -X 的绘制距离与 log(log(X)) 从 0- 且 Y 轴采用对数刻度

如何用Python重现它?

选项:

fig, ax = plt.subplots()
plt.xscale('log')
ax.scatter(p, mult, facecolor='blue', marker='.', s=10)
plt.show()

不一样:

python matplotlib plot
1个回答
0
投票
import numpy as np
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

ticks = [np.log(np.log(10)),np.log(np.log(10**2)),np.log(np.log(10**3)),
         np.log(np.log(10**4)),np.log(np.log(10**5)),np.log(np.log(10**6))]
ax.set_xticks(ticks)

labels = [r'$10^1$',r'$10^2$',r'$10^3$',r'$10^4$',r'$10^5$',r'$10^6$']
ax.set_xticklabels(labels)

plt.tight_layout()
plt.show()
© www.soinside.com 2019 - 2024. All rights reserved.