I am plotting values that are of order 10^-8 and I would like my inline plot in jupyter to output the yaxis ticks in that (scientific) notation. I tried :
plt.gca().yaxis.set_major_formatter(FormatStrFormatter('%.1E'))
as well as
plt.gca().yaxis.get_major_formatter().set_powerlimits((0, -10))
and
plt.ticklabel_format(style='sci')
but nothing seems to work. What am I doing wrong? I have the following example:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import mpld3
mpld3.enable_notebook()
import matplotlib.ticker as mtick
a=5*10**-8
b=3*10**-8
x=np.arange(0,10,0.01)
y=a*x+b
plt.figure(figsize=(12,5))
plt.subplot(1,2,1)
plt.plot(x,y)
# plt.ticklabel_format(style='sci')
# plt.gca().yaxis.get_major_formatter().set_powerlimits((0, -10))
plt.gca().yaxis.set_major_formatter(mtick.FormatStrFormatter('%.0e'))
plt.show()
Any pointers would be helpful as I don't find anything on this, besides ticks format of an axis in matplotlib, enter link description here or Change x axes scale in matplotlib
NOTE: If I comment out the lines with import mpld3
and mpld3.enable_notebook()
then it works but cannot interact with the plot... Is there some special treatment of matplotlib when plotting inline in jupyter?
Thanks!