Skip to content

Instantly share code, notes, and snippets.

@jsundram
Forked from mdboom/alignment.py
Last active December 16, 2015 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsundram/5422685 to your computer and use it in GitHub Desktop.
Save jsundram/5422685 to your computer and use it in GitHub Desktop.
allow dynamic backend setting; name files after backend they were rendered from for clarity.
import matplotlib, sys
backend = sys.argv[1]
matplotlib.use(backend) # need to call use() before importing pyplot
from matplotlib.pyplot import *
text(0.1, 0.5, "Top Tj", verticalalignment="top")
text(0.2, 0.5, "Bottom Tj", verticalalignment="bottom")
text(0.3, 0.5, "Base Tj", verticalalignment="baseline")
text(0.4, 0.5, "Center Tj", verticalalignment="center")
text(0.5, 0.5, "Top Tj", rotation=30, verticalalignment="top")
text(0.6, 0.5, "Bottom Tj", rotation=30, verticalalignment="bottom")
text(0.7, 0.5, "Base Tj", rotation=30, verticalalignment="baseline")
text(0.8, 0.5, "Center Tj", rotation=30, verticalalignment="center")
text(0.1, 1.0, r"$\sum_{i=j}$", verticalalignment="top")
text(0.2, 1.0, r"$\sum_{i=j}$", verticalalignment="bottom")
text(0.3, 1.0, r"$\sum_{i=j}$", verticalalignment="baseline")
text(0.4, 1.0, r"$\sum_{i=j}$", verticalalignment="center")
text(0.5, 1.0, r"$\sum_{i=j}$", rotation=30, verticalalignment="top")
text(0.6, 1.0, r"$\sum_{i=j}$", rotation=30, verticalalignment="bottom")
text(0.7, 1.0, r"$\sum_{i=j}$", rotation=30, verticalalignment="baseline")
text(0.8, 1.0, r"$\sum_{i=j}$", rotation=30, verticalalignment="center")
plot([0, 1], [0.5, 0.5])
plot([0, 1], [1.0, 1.0])
ylim([0, 1.5])
savefig("%s.png"% backend)
savefig("%s.pdf"% backend)
savefig("%s.svg"% backend)
savefig("%s.ps" % backend)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment