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()

Figure

我想获得一个看起来与第二个相似的颜色条,但是没有明确指定刻度标签

我还尝试设置rcParams['axes.formatter.uSEOffset'] = False,但没有成功。

我正在使用matplotlib版本3.3.1

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)