bnwebcode / xpyplot

matplotlib wrapper that keeps data together with the figures

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

xpyplot

A small utility library that captures calls to matplotlib's pyplot interface and saves the data being plotted together with the plotting commands. In this way it allows easy re-plotting when the user's otherwise omitted to keep proper record of the data.

For example:

import xpyplot as plt
import numpy

x=numpy.array([1,2,3])
plt.plot(x, x*2+1)
plt.savefig("testsample.png")

will produce the expected plot `testsample.png` but also a script `testsample.script.py`:

plot1=numpy.load(open("testsample.plot1.npy", "rb"))
plot0=numpy.load(open("testsample.plot0.npy", "rb"))
pyplot.plot(*[plot0, plot1, ], **{}, scalex=True, scaley=True, data=None, )
pyplot.savefig(fname="testsample.png", )

and two numpy array files `testsample.plot1.npy` and `testsample.plot0.npy`. Running the generated script will reproduce the original plot.

See also

There is a short write-up at: http://www.bnikolic.co.uk/blog/python/2020/01/06/xpyplot.html

About

matplotlib wrapper that keeps data together with the figures

License:BSD 2-Clause "Simplified" License


Languages

Language:Python 100.0%