Skip to content

Instantly share code, notes, and snippets.

@jzrake
Created July 3, 2012 16:47
Show Gist options
  • Select an option

  • Save jzrake/3040949 to your computer and use it in GitHub Desktop.

Select an option

Save jzrake/3040949 to your computer and use it in GitHub Desktop.
matplotlib tutorial 1
#!/usr/bin/env python
if __name__ == "__main__":
import sys
import numpy as np
from matplotlib import pyplot as plt
infile = sys.argv[1]
data = np.loadtxt(infile)
x = data[0,:]
y1 = data[1,:]
y2 = data[2,:]
# keywords for styles:
# --------------------------------------------------------------------------
# ls, linestyle ... '..', '.-', '-', '--'
# lw, width ... 1 is the default
# c, color ... obvious, except for k: black
# mfc: marker face color
plt.semilogx(x, y1, c='k', ms=5, marker='x', ls='-.', label="series 1")
plt.semilogx(x, y2, c='k', ms=5, marker='o', ls='--', label="the!")
plt.xlabel(r"the $x_\xi$ axis", fontsize=18)
plt.ylabel(r"the $\mathbf{y_\rho}$ axis", fontsize=18)
plt.title("that's it")
plt.legend(loc="best")
plt.show()
# for a hardcopy, use
# plt.savefig("hardcopy.ps")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment