View on GitHub

Prefig

An awesome plotting object to make any plot poster or presentation ready in the colours of your choice!

Download this project as a .zip file Download this project as a tar.gz file

Ever been disgusted at seeing a white plot on a black background?

How about a tiny plot blown up to the size of a presentation slide so that it's blurry and unreadable?

Plots in papers can look beautiful but the format needs to be different for presentations and posters.

For example if we have some randomly generated linear data with some randomly generated errors:

x = np.linspace(8,10,50)+ np.random.normal(0,0.5, 50)
m, c = 1.5, -3
y = m*x + c + np.random.normal(0,0.5,50)
yerr = np.random.normal(0,0.1,50)

We can plot this with matplotlib as follows:

import matplotlib.pylab as plt
plt.figure()
plt.errorbar(x, y, yerr, fmt=' ', marker='D')
plt.plot(x, (m*x+c))
plt.xlabel('measured')
plt.ylabel('observed')

With the matplotlib defaults, that looks something like this on a presentation slide:

default

If instead we use the Prefig() class rather than plt.figure() for our plot:

Prefig(axcol='w', fontcol='w')
plt.errorbar(x,y, yerr, xerr=None, fmt=' ', marker='D')
plt.plot(x, (m*x+c))
plt.xlabel('measured')
plt.ylabel('observed')

Prefig returns something like this:

prefig

The background of the image returned by prefig is transparent so we can even overlay it over background images in presentations:

prefig_background

The defaults create a plot the same size as a presentation slide, (16,12) inches and if white is input as the font colour, the default python plotting colours are inverted.

prefig is awesome! - everyone, everywhere.