I am trying to convert a figure created with matplotlib into html to embed it into a web page with mpld3.fig_to_html
method. For some reasons, the scientific notation is lost on the y-axis. If I try to save a local .png image the scientific notation is shown correctly.
Moreover if I save a local .html file with mpld3.save_html
the scientific notation is lost as well.
Any idea ?
Here's an example:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import mpld3
from matplotlib import ticker
t = [130940239,30492094,20394029]
s = [3898298328,3498328998234,39482]
fig, ax = plt.subplots()
formatter1 = ticker.ScalarFormatter(useMathText=True)
formatter1.set_scientific(True)
formatter1.set_powerlimits((0, 0))
ax.yaxis.set_major_formatter(formatter1)
ax.plot(t, s)
html_str = mpld3.fig_to_html(fig)
ax.grid()
mpld3.save_html(fig,"test_dummy.html")
fig.savefig("test.png")