Artemis Plotting

Live Plots with dbplot

dbplot is an easy way to create a live plot of your data.

For example, to create live updating plots of a random grid:

from artemis.plotting.db_plotting import dbplot
import numpy as np

for _ in xrange(50):
    dbplot(np.random.randn(20, 10), 'random data')

A plot will come up showing the random data.

from artemis.plotting.db_plotting import dbplot
import numpy as np

for _ in xrange(50):
    dbplot(np.random.randn(20, 10), 'random line data', plot_type='line')

You can include multiple plots:

from artemis.plotting.db_plotting import dbplot
import numpy as np

for _ in xrange(50):
    dbplot(np.random.randn(20, 2), 'random line data', plot_type='line')
    dbplot(np.random.randn(10, 10), 'random grid data')

If you plot many things, you may want to “hold” your plots, so that they all update together. This speeds up the rate of plotting:

from artemis.plotting.db_plotting import dbplot, hold_dbplots
import numpy as np

for _ in xrange(50):
    with hold_dbplots():
        dbplot(np.random.randn(20, 2), 'random line data', plot_type='line')
        dbplot(np.random.randn(10, 10), 'random grid data')
        dbplot(np.random.randn(4), 'random line history')
        dbplot(np.random.rand(3), 'random bars', plot_type='bar')
        dbplot([np.random.rand(20, 20), np.random.randn(20, 16, 3)], 'multi image')

dbplot documentation

artemis.plotting.db_plotting.dbplot(data, name=None, plot_type=None, axis=None, plot_mode='live', draw_now=True, hang=False, title=None, fig=None, xlabel=None, ylabel=None, draw_every=None, layout=None, legend=None, grid=False, wait_for_display_sec=0, cornertext=None, reset_color_cycle=False)[source]

Plot arbitrary data and continue execution. This program tries to figure out what type of plot to use.

Parameters:
  • data – Any data. Hopefully, we at dbplot will be able to figure out a plot for it.
  • name – A name uniquely identifying this plot.
  • plot_type – A specialized constructor to be used the first time when plotting. You can also pass certain string to give hints as to what kind of plot you want (can resolve cases where the given data could be plotted in multiple ways): ‘line’: Plots a line plot ‘img’: An image plot ‘colour’: A colour image plot ‘pic’: A picture (no scale bars, axis labels, etc).
  • axis – A string identifying which axis to plot on. By default, it is the same as “name”. Only use this argument if you indend to make multiple dbplots share the same axis.
  • plot_mode – Influences how the data should be used to choose the plot type: ‘live’: Best for ‘live’ plots that you intend to update as new data arrives ‘static’: Best for ‘static’ plots, that you do not intend to update ‘image’: Try to represent the plot as an image
  • draw_now – Draw the plot now (you may choose false if you’re going to add another plot immediately after and don’t want have to draw this one again.
  • hang – Hang on the plot (wait for it to be closed before continuing)
  • title – Title of the plot (will default to name if not included)
  • fig – Name of the figure - use this when you want to create multiple figures.
  • grid – Turn the grid on
  • wait_for_display_sec – In server mode, you can choose to wait maximally wait_for_display_sec seconds before this call returns. In case plotting is finished earlier, the call returns earlier. Setting wait_for_display_sec to a negative number will cause the call to block until the plot has been displayed.

Browser-Plotting

After installing, you should have a file ~/.artemisrc.

To use the web backend, edit the backend field to matplotlib-web.

To try it you can run the commands described above for dbplot.