Skip to content

Latest commit

 

History

History
50 lines (25 loc) · 1.74 KB

README.md

File metadata and controls

50 lines (25 loc) · 1.74 KB

sparklpy

DOI Code Health

module to create Tufte-style spark line plots for time series, including astronomical ones (in magnitude!)

(acknowledgement - the author thaks MTA for their service: this code was written almost entirely during NYC subway trips)

this is a pure module (a single .py and a single function really) that creates a sparkline plot a-la' Tufte.

It eats time series in the form of 2d numpy.ndarrays, or dataframes

You can control a number of settings including the figure layout (number of columns and rows) the colors that mark the minimum and maximum, the label format and size.

It will temporarely overwrite your rc.param, but no panic: it will reset them to your default before exiting the function.

The resulting plot will look something like this:

alt text

The upon calling it, with argument a nd.numpy array (shape = (n_observations, n_timestamps) or a dataframe (all columns must be nuerical values) the function returns a pylab figure object, which you can display (pl.show() ) or save (pl.savefig() ).

install the package "sparkleme" as

python setup.py install .

or just save the sparkleme directory somwhere in your python path and call the module sparkleme. Either way import as

import sparkleme

and call, for example, as


fig = sparkleme.sparkleme(data)

fig.show()

To test that the module works run

sparkleme.sparkletest()

or you can use the sparkletest.ipynb Jupyter notebook.