Skip to content Skip to sidebar Skip to footer

Can't Save Figure As .eps [gswin32c Is Not Recognized]

I'm using Enthought Canopy with PyLab(64-bit). For my report I need to use Latex (XeLaTex) and the plots are done with matplotlib. To have an first idea I just copied the second ex

Solution 1:

I finally managed to solve this problem. It might look weird but maybe other people can benefit from it.

The solution might depend upon the software you use. I use Enthought Canopy (Python) and MikTeX 2.9 under W8 64bit. If you want to output .ps and .eps files with matplotlib using the 'text.usetex': True option then you will encounter the problem posted above.

Answer :

  1. Download and install Ghostscript (32bit) from http://www.ghostscript.com/download/gsdnld.html.
  2. Download ps2eps-1.68.zip from http://www.tm.uka.de/~bless/ps2eps. The proceeding is given in the manual, however I like to point out the part with the environment variables. In this last step you need to go to Control Panel --> System --> Advanced system settings. Then click on the header 'Advanced' and on the bottom of the window you see 'Environment Variables' on which you click. Then you use the 'New'-Button for User Variables for USERNAME. Then you type in as variable name 'ps2eps' and for variable value you type in the actual path where you have saved the ps2eps.pl file. In my case this is 'C:\Program Files (x86)\ps2eps\bin\'. You can check if you type 'ps2eps' in the command-window.
  3. Download xpdfbin-win-3.03.zip from http://www.foolabs.com/xpdf/download.html. You only need the file 'pdftops.exe'. However I could not assign a path like in step 2. I solved this by putting the 'pdftops.exe' in the MikTeX 2.9 folder. The exact location for me was 'C:\Program Files\MiKTeX 2.9\miktex\bin\x64'.

I was then able to save figures as .ps and have no more any error messages. Remember to use the settings proposed on http://matplotlib.org/users/usetex.html under 'postscript options'. In myself used the following settings:

#!/usr/bin/env python# -*- coding: utf-8 -*-import matplotlib as mpl
mpl.rc('font', **{'family':'serif', 'serif':['Computer Modern Roman'],
              'monospace':['Computer Modern Typewriter']})
params = {'backend': 'ps',
      'text.latex.preamble': [r"\usepackage{upgreek}",
                              r"\usepackage{siunitx}",
                              r"\usepackage{amsmath}",
                              r"\usepackage{amstext}",],
      'axes.labelsize': 18,
      #'axes.linewidth': 1,#'text.fontsize':17,'legend.fontsize': 10,
      'xtick.labelsize': 13,
      #'xtick.major.width' : 0.75,'ytick.labelsize': 13,
      'figure.figsize': [8.8,6.8],
      #'figure.dpi': 120,'text.usetex': True,
      'axes.unicode_minus': True,
      'ps.usedistiller' : 'xpdf'}          
mpl.rcParams.update(params)
mpl.rcParams.update({'figure.autolayout':True})

(whereas many of the params are just for my own purpose later in the plots)

As a beginner I am not well informed about the dependence from the 'backend' used if you are running a script from your python console. I however used this without any --pylab settings in before and I do not know if one needs to switch the backend manually if he is working already in a console with a specific matplotlib backend.

Solution 2:

I had the same problem and my problem was a font adjustment in the python code that is :

from matplotlib import rc 
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
rc('text', usetex=True)

when I remove this iit works fine and now i can save eps. So be sure that any shortest working example is working for you or not then check the font and other style edits in your code. This may help.

Post a Comment for "Can't Save Figure As .eps [gswin32c Is Not Recognized]"