garrettj403 / SciencePlots

Matplotlib styles for scientific plotting
MIT License
7.12k stars 709 forks source link

Latex Option Clash when Saving Figure #3

Closed qantik closed 5 years ago

qantik commented 5 years ago

Trying to save a figure using the savefig routine throws the following latex compilation error on my machine with MacTeX-2018 installed:

! LaTeX Error: Option clash for package graphicx.

Here is a minimal example that produces the failure.

import matplotlib as plt

with plt.style.context('science'):
    plt.plot([1, 2, 3, 4], [1, 2, 3, 4])
    plt.savefig('figure.eps', format='eps')

The compilation and subsequent saving work fine if the pgfplots packages is removed from the preamble directive in science.mplstyle. I'm not sure how this change affects the figures.

text.latex.preamble : \usepackage{amsmath}, \usepackage[T1]{fontenc}

garrettj403 commented 5 years ago

Hi @qantik Thanks for pointing that out. I didn't realize that the package would clash with EPS files. I've now removed \usepackge{pgfplots} from science.mplstyle, and put it into its own style (pgf.mplstyle).