I am using Spyder to edit python code. I plotted a figure like following on my screen:
As you can see I have zoom-in on my menu by playing which I can magnify a ROI like following:
Now I need to send this figure to another person who'd like to view this figure interactively, say do zoom-in/zoom-out as well.So my question is, is there anyway to send this figure in certain format the other person can play with such that me without sending my entire python code?
I tried to the save icon on the menu bar, but I did not see a format that can do what I want. I am new to python, please advice. Thank you.
PS: I think in MATLAB you can do that by saving the figure in certain format, so that as long as the other person has MATLAB installed, he/she does not need the data to see the figure interactively
You need to use the pickle
module.
MATLAB saves the figure in a .fig
format. This is really just a .mat
MATLAB data file with a different extension so MATLAB knows it stores image data. If you change the extension to .mat
, you can open it is a refular MATLAB data file and see that it just contains variables storing image information.
The equivalent thing to do in matplotlib is to use the pickle.dump
function to save the matplotlib figure
object to a file. Someone else can then just load the figure from the file and show
it. Although the other person may need to have the same matplotlib version installed.
A better option would be to use something like bokeh
to save an interactive HTML plot.