1

For some reason, I can't find a way to turn off the scientific notation of the colorbar for the following plot:

enter image description here

I've tried using powerlimits:

ylabels = ['0:00', '03:00', '06:00', '09:00', '12:00', '15:00', '18:00', '21:00']

fig, ax = plt.subplots(figsize=(27, 7))

cax1 = ax.imshow(df7, origin='lower', cmap='viridis', interpolation='none', aspect=4)
ax.set_xticklabels(label, fontsize = 12)
plt.xticks(np.arange(len(df7.columns)))

major_ticks = np.arange(0, 24, 3)
ax.set_yticks(major_ticks)
ax.set_yticklabels(ylabels, fontsize = 12)


fig.autofmt_xdate()


cb = plt.colorbar(cax1,fraction=0.046, pad=0.04)
cb.formatter.set_powerlimits((0, 8))
cb.update_ticks

plt.tight_layout()

ax.set_aspect(0.5)
fig.suptitle('November 2016 Normalized Pressure Data $[mbar]$',fontsize=15)
fig.tight_layout(pad = 1)

plt.show()

I've seen the similar question about formatting the colorbar, but here the question is how to format it for disabling the scientific notation!

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
ValientProcess
  • 1,699
  • 5
  • 27
  • 43
  • 1
    Possible duplicate of [Scientific notation colorbar in matplotlib](http://stackoverflow.com/questions/25983218/scientific-notation-colorbar-in-matplotlib) – MB-F Feb 10 '17 at 07:32
  • The question is different, but the answer should solve this problem too. – MB-F Feb 10 '17 at 07:34
  • I need to disable it rather then enabling it, I don't see how this can work. thanks – ValientProcess Feb 10 '17 at 07:34
  • Did you try the answer, or at least read it? Enabling and disabling something often works through the same command or parameter. In this case the key is to set the `format` option of the color bar. (note the second, less up-voted answer for a one-line solution) – MB-F Feb 10 '17 at 07:38

1 Answers1

5

Found the solution myself:

using these lines:

fmt = '%1.2f'
cb = plt.colorbar(cax1,fraction=0.046, pad=0.04, format = fmt)

and removing the line:

cb.formatter.set_powerlimits((0, 8))
ValientProcess
  • 1,699
  • 5
  • 27
  • 43