Plotting with Matplotlib

See here for some examples. The codes here show how to set plot parameters in one place and use it in other scripts.

Global font setting

from matplotlib.pyplot import rc
rc('font', size=16)
rc('font', family='serif') # for Times New Roman font (looks good)
rc('text', usetex=True)    # This will use Latex fonts (slow)

Tight axis

To make both axes tight

plt.axis('tight')

Make x axis tight

plt.autoscale(enable=True, axis='x', tight=True)

Set axes range

To set both axes

plt.axis([0, 1, -1, 1])

To set independently

plt.xlim(0,1)
plt.ylim(-1,1)