显示XTICKS作为日志量表的整数

发布于 2025-01-23 13:08:31 字数 1002 浏览 1 评论 0原文

我正在尝试使用我已经拥有的数据来复制以下散点图。该图绘制了f_n vs n vs n在日志刻度(黑色点)上,但是x轴和y轴代表实际数字,而不是10的幂。蓝线是最佳拟合的线,可以忽略。基于这个问题的答案,我试图制定x-axis使用 tick-formating api ,但我无法获得适当的格式以显示出适当的格式以显示出的诸如诸如的任意数字(2,5,20,50)。此外,我应该如何选择性地选择y轴的壁虱,我尝试了 LogLocator 但也无法工作。

欢迎任何帮助或建议。先感谢您!

I'm trying to replicate the following scatterplot with the data I already have. The figure plots F_n vs n on a log-log scale (black dots) but the x-axis and y-axis represent the actual numbers and not the powers of 10. The blue line is the line of best fit and can be ignored. Based on the answers to this question, I have tried to formate the x-axis using ScalarFormatter and the tick-formating API but I am unable to get the proper formatting to display arbitrary numbers like (2,5,20,50). Furthermore, how should one selectively pick the ticks for the y-axis, I tried the LogLocator but it did not work either.

enter image description here

Any help or suggestions are welcome. Thank you in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不必在意 2025-01-30 13:08:31

实现这一目标的一种方法是使用XTICKSyticks。这是一个示例:

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(1, 200)
y = 0.1 * (x / x[0])**(np.log10(1e-07/0.1) / np.log10(x[-1]/x[0]))

plt.figure()
plt.plot(x, y)
plt.xscale("log")
plt.yscale("log")
plt.xticks([1, 2, 5, 10, 20, 50, 100, 200], [1, 2, 5, 10, 20, 50, 100, 200])
plt.yticks([0.01, 1e-04, 1e-06], [0.01, "1e-04", 1e-06])
plt.minorticks_off()
plt.show()

“在此处输入图像描述”

One way to achieve that is to play with xticks and yticks. Here is an example:

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(1, 200)
y = 0.1 * (x / x[0])**(np.log10(1e-07/0.1) / np.log10(x[-1]/x[0]))

plt.figure()
plt.plot(x, y)
plt.xscale("log")
plt.yscale("log")
plt.xticks([1, 2, 5, 10, 20, 50, 100, 200], [1, 2, 5, 10, 20, 50, 100, 200])
plt.yticks([0.01, 1e-04, 1e-06], [0.01, "1e-04", 1e-06])
plt.minorticks_off()
plt.show()

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文