I'm using mpld3 to display graphs on an intranet website. I'm using the option of saving the graph to a dict and render it on the client side using mpld3.js.
The graph renders fine except when I want to use annotations. Those ones are clearly offset. And I don't understand why, because even if I set the offset to (0, 0), the annotations are still way off.
To illustrate this, I have copied and pasted the example given in this post: Matplotlib: How to put individual tags for a scatter plot
Here is the image as correctly generated by matplotlib:
Here is the one made with mpld3:
Note that both image are generated at the same time using the code in the link mentioned above. The matplotlib one is made using:
plt.show()
and then manually saved.
The one from mpld3 is made using:
graph_data = json.dumps(fig_to_dict(fig))
Then graph_data
is generated on the client side using mpld3.js
, which works perfectly fine except when using annotations.
Do you have any idea why it behaves like this? Eventually I could just display the images generated directly from matplotlib, but the have interactive chart is a nice bonus.