问题
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"]
回答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.
回答2:
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 Import
ing 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]
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)
来源:https://stackoverflow.com/questions/18647024/how-can-i-import-eps-in-mathematica-without-losing-the-text