我有一个条形图,它看起来像我想要的样子,除了 y 轴上的科学记数法之外。
其他一些解决方案包括使用
ax.yaxis.set_major_formatter(tick)
Run Code Online (Sandbox Code Playgroud)
这不起作用。另外,我尝试检查这是否是一个偏移问题,但它应该显示一个“+”号,但在本例中没有。
每当我使用:
plt.ticklabel_format(style='plain')
Run Code Online (Sandbox Code Playgroud)
我收到一条错误消息:
Traceback (most recent call last):
File "C:\Python\lib\site-packages\matplotlib\axes\_base.py", line 2831, in ticklabel_format
self.xaxis.major.formatter.set_scientific(sb)
AttributeError: 'FixedFormatter' object has no attribute 'set_scientific'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Python/Projects/Kaggle 1.py", line 13, in <module>
plt.ticklabel_format(style='plain')
File "C:\Python\lib\site-packages\matplotlib\pyplot.py", line 2982, in ticklabel_format
useMathText=useMathText)
File "C:\Python\lib\site-packages\matplotlib\axes\_base.py", line 2856, in ticklabel_format
"This method only works with the ScalarFormatter.")
AttributeError: This method only works with the ScalarFormatter.
Run Code Online (Sandbox Code Playgroud)
我研究过这个 ScalarFormatter,但我无法更清楚地了解它为什么不起作用。我尝试将其显式包含在代码中,但它不起作用。 …