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)

Line width and marker size

lw = 3 # linewidth
ms = 8 # marker size

Tight axis

To make both axes 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