Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't know of any native Matplotlib file format which includes your data; in fact, I'm not sure the Matploblib objects even have a write function defined.</p> <p>What I do instead to simulate the Matlab .fig concept is to save the processed data (as a numpy array, or pickled) and run a separate .py script to recreate the Matplotlib plots.</p> <p>So in steps:</p> <ol> <li>Process your data and make some pretty plots until you are fully content</li> <li>Save/pickle your processed data as close to the plot commands as possible (you might even want to store the data going into a histogram if making the histogram takes a long time)</li> <li>Write a new script in which you import the data and copy/paste the plotting commands from the original script</li> </ol> <p>It is a bit clumsy, but it works. If you really want, you could embed the pickled data as a string in your plotting script (<a href="https://stackoverflow.com/questions/1887968/embed-pickle-or-arbitrary-data-in-python-script">Embed pickle (or arbitrary) data in python script</a>). This gives you the benefit of working with a single python script containing both the data as well as the plotting code.</p> <h2>Edit</h2> <p>You can check for the existence of your stored processed data file and skip the processing steps if this file exists. So:</p> <pre><code>if not processed_data.file exists: my_data = process_raw_data() else: my_data = read_data_from_file(processed_data.file) plot(my_data) </code></pre> <p>In this way, you can have one script for both creating the graph in the first place, and re-plotting the graph using pre-processed data.</p> <p>You might want to add a runtime argument for forcing a re-processing of the data in case you change something to the processing script and don't want to manually remove your processed data file.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload