0

I am trying to import a histogram produced by Stata as an .eps file into Mathematica, but it does not display axes' labels. That is, for some reason, Mathematica does not import .eps as but rather transforms it.

How can I avoid that? As of now, I am using plain

Import["~/hst.eps"]
Alexey Popkov
  • 9,355
  • 4
  • 42
  • 93
P.Escondido
  • 3,373
  • 6
  • 23
  • 29
  • possible duplicate of [How can I convert .eps file to .pdf in Mathematica?](http://stackoverflow.com/questions/18647607/how-can-i-convert-eps-file-to-pdf-in-mathematica) – Nick Cox Sep 06 '13 at 08:51
  • @Nick I think these questions have different scope although the question you linked is formulated very similar to this question. I think we should separate these questions: this is about importing .eps in *Mathematica*, [that](http://stackoverflow.com/q/18647607/590388) question is about converting .eps to .pdf in *Mathematica*. I will edit them appropriately. – Alexey Popkov Sep 06 '13 at 15:41
  • That's helpful. The original problem was the posting of two closely related questions, but if you can pull them apart, that's good. – Nick Cox Sep 06 '13 at 16:00
  • You might consider flagging your question for migration to [Mathematica.SE]. – Mr.Wizard Sep 09 '13 at 08:41
  • 1
    upload a simple test EPS file to a suitable web site and it will be easier to find out what's going wrong – cormullion Sep 10 '13 at 09:09
  • 1
    sure, this is the sample file https://dl.dropboxusercontent.com/u/824842/orders_weekly.eps – P.Escondido Sep 10 '13 at 22:44

2 Answers2

1

I had a similar problem with LateX and a pdf graph recently, which also manifested itself with the eps version. I wound up modifying the user-written graphexportpdf and things seemed to work out. Perhaps you will find this solution helpful.

Community
  • 1
  • 1
dimitriy
  • 9,077
  • 2
  • 25
  • 50
0

Mathematica currently (v.9) usually cannot import textual elements from .eps files properly. One possible solution would be to export your plot as .pdf rather than .eps from you plotting software and then Import generated .pdf. If you need to import the text as text you can turn off outlining by using the "TextOutlines" -> False option.

If exporting to .pdf from your plotting software is not possible you can convert .eps to .pdf by another program and then Import generated .pdf as above. For your file orders_weekly.eps using the gsEPS2PDFEmbedFonts function and then Importing generated .pdf, I get (Mathematica 8.0.4):

gsEPS2PDFEmbedFonts["orders_weekly.eps", "orders_weekly.pdf"]
graphics=First@Import["orders_weekly.pdf"(*,"TextOutlines"->False*)];
Show[graphics, Frame -> True, PlotRange -> All, ImageSize -> Automatic]

plot

I have commented the "TextOutlines" -> False option because Mathematica 8.0.4 still imports rotated text incorrectly with it. I haven't tested it with v.9 though.


Another possibility is to convert all the glypth in the .eps file to oultines. Based on Jens Nöckel's code,

gsEPS2outlinedEPS[epsPath_String, outlinedEPSPath_String] := 
 Run["gswin64c.exe -sDEVICE=epswrite -dNOCACHE -sOutputFile=\"" <> 
   outlinedEPSPath <> "\" -q -dbatch -dNOPAUSE \"" <> epsPath <> 
   "\" -c quit"]

Here gswin64c.exe is the name of GhostScript executable for 64bit Windows systems, for Linux replace it with gs. Note that you should have GhostScript installed and configured (for Windows you should add gs\bin and gs\lib to the PATH, where gs is the top-level Ghostscript directory)

Community
  • 1
  • 1
Alexey Popkov
  • 9,355
  • 4
  • 42
  • 93