如何解决Matplotlib颜色条没有偏移符号
我正在尝试绘制带有科学且没有偏移符号的颜色条。设置colorbar.formatter.set_useOffset(False)
(https://stackoverflow.com/a/29280475/10734962)不起作用。
import matplotlib.pyplot as plt
import numpy as np
CMIN,CMAX = 5e15,1e16
# Create axes
figure_h,axes_h = plt.subplots(3,figsize=(5,8))
# Create data
data = np.random.uniform(CMIN,CMAX,(10,10))
# Plot -- default
plot_h = axes_h[0].imshow(data,cmap='jet',clim=(CMIN,CMAX))
c = plt.colorbar(plot_h,ax=axes_h[0])
# Plot -- manual ticks
plot_h = axes_h[1].imshow(data,CMAX))
colorbar_h = plt.colorbar(plot_h,ax=axes_h[1])
colorbar_h.set_ticks(colorbar_h.get_ticks()) # To prevent 'UserWarning: set_ticks() must have been called.'
colorbar_h.set_ticklabels([f'{f:.0e}' for f in colorbar_h.get_ticks()])
# Plot -- no offset notation
plot_h = axes_h[2].imshow(data,ax=axes_h[2])
colorbar_h.formatter.set_useOffset(False)
colorbar_h.update_ticks()
plt.show()
我想获得一个看起来与第二个相似的颜色条,但是没有明确指定刻度标签。
我还尝试设置rcParams['axes.formatter.useoffset'] = False
,但没有成功。
我正在使用matplotlib版本3.3.1
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。