- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我已经尝试在 pyplot 中抑制科学记数法几个小时了。在尝试了多种解决方案均未成功后,我需要一些帮助。
plt.plot(range(2003,2012,1),range(200300,201200,100))
# several solutions from other questions have not worked, including
# plt.ticklabel_format(style='sci', axis='x', scilimits=(-1000000,1000000))
# ax.get_xaxis().get_major_formatter().set_useOffset(False)
plt.show()
Is ticklabel_format broken?并不能解决实际移除偏移量的问题。
plt.plot(np.arange(1e6, 3 * 1e7, 1e6))
plt.ticklabel_format(useOffset=False)
最佳答案
在您的情况下,您实际上想要禁用偏移量。使用科学记数法是与根据偏移值显示事物不同的设置。
但是,ax.ticklabel_format(useOffset=False)
应该有效(尽管您已将其列为无效的事情之一)。
例如:
fig, ax = plt.subplots()
ax.plot(range(2003,2012,1),range(200300,201200,100))
ax.ticklabel_format(useOffset=False)
plt.show()
如果您想同时禁用偏移量和科学记数法,您可以使用 ax.ticklabel_format(useOffset=False, style='plain')
。
在 matplotlib 轴格式中,“科学记数法”指的是数字显示的乘数,而“偏移量”是一个单独的术语,添加。 p>
考虑这个例子:
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(1000, 1001, 100)
y = np.linspace(1e-9, 1e9, 100)
fig, ax = plt.subplots()
ax.plot(x, y)
plt.show()
x 轴将有一个偏移量(注意 +
符号),y 轴将使用科学计数法(作为乘数 -- 无加号)。
我们可以单独禁用其中一个。最方便的方法是 ax.ticklabel_format
方法(或 plt.ticklabel_format
)。
例如,如果我们调用:
ax.ticklabel_format(style='plain')
我们将禁用 y 轴上的科学记数法:
如果我们调用
ax.ticklabel_format(useOffset=False)
我们将禁用 x 轴上的偏移,但保持 y 轴科学计数法不变:
最后,我们可以通过以下方式禁用两者:
ax.ticklabel_format(useOffset=False, style='plain')
关于python - 防止科学记数法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28371674/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 6年前关闭。 Improve this qu
我有实体: @Entity @Table(name = "CARDS") public class Card { @ManyToOne @JoinColumn(name = "PERSON_I
我正在尝试计算二维多边形的表面法线。我正在使用 OpenGL wiki 中的 Newell 方法来计算表面法线。 https://www.opengl.org/wiki/Calculating_a_S
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 关闭 7 年前。 Improve
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 9 年前。 Improve this
我这里有以下 XML: Visa, Mastercard, , , , 0, Discover, American Express siteonly, Buyer Pay
即将发生的 Google 政策变更迫使我们实现一个对话框,以通知欧盟用户有关 Cookie/设备标识符用于广告和分析的情况。我只想向欧盟用户显示此对话框。我不想使用额外的权限(例如 android.p
本文分享自华为云社区《华为大咖说 | 企业应用AI大模型的“道、法、术” ——道:认知篇》,作者:华为云PaaS服务小智。 本期核心观点 上车:AGI是未来5~10年内,每个人都无法回避的技
我有一个与酒精相关的网站,需要先验证年龄,然后才能让他们进入该网站。我使用 HttpModule 来执行此操作,该模块检查 cookie,如果未设置,我会将它们重定向到验证页面。我验证他们的年龄并存储
在欧盟,我们有一项法律,要求网页请求存储 cookie 的许可。我们大多数人都了解 cookie 并同意它们,但仍然被迫在任何地方明确接受它们。所以我计划编写这个附加组件(ff & chrome),它
以下在 C 和/或 C++ 中是否合法? void fn(); inline void fn() { /*Do something here*/ } 让我担心的是,第一个声明看起来暗示函数将被定义
我是一名优秀的程序员,十分优秀!