Skip to content

Instantly share code, notes, and snippets.

@basilfx
Created May 13, 2014 14:18
Show Gist options
  • Select an option

  • Save basilfx/81d926afa576d1ee52df to your computer and use it in GitHub Desktop.

Select an option

Save basilfx/81d926afa576d1ee52df to your computer and use it in GitHub Desktop.
Matplotlib LaTeX look
import matplotlib
TEXT_WIDTH = 452.9679 #pt
FONT_NORMAL_SIZE = 10.0 #pt
PT_TO_INCH = 0.01388888889
# Configure matplotlib to render LaTeX style
matplotlib.rc("font", family="serif", size=FONT_NORMAL_SIZE)
matplotlib.rc("text", usetex=True)
def render(figure, filename, width=1.0, height=0.6):
figure.tight_layout()
figure.set_size_inches(width * TEXT_WIDTH * PT_TO_INCH, height * TEXT_WIDTH * PT_TO_INCH)
figure.savefig(filename, bbox_inches='tight')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment