I´am trying to import a matlab histogram to latex. So I generated the plot and saved it with
print -depsc MyPicture.
Afterwards I loaded the .eps File with

\includegraphics[width=.8\textwidth, center]{pictures/MyPicture.eps}

The resulting image has a really low quality.

enter image description here

The above mentioned method works fine with normal graph plots.

Edit: I found a workaround using the matlab2tikz script, which generates a tex-File.

Solution: I used -dpdf to save the plot and used this matlab code to cut the white spaces.

  • 1
    Something somewhere is converting to .jpg. The jpg may be embedded in a pdf. What are you comping with (latex, pdflatex etc?). If you're compiling directly to pdf, how are you converting the .eps?
    – Chris H
    Oct 7, 2019 at 12:49
  • 1
    Can you view your eps directly and check if it is blurry? Matlab prints bitmaps for certain colour surfaces, even if you ask for vector graphics.
    – ebcontrol
    Oct 7, 2019 at 12:57
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Oct 7, 2019 at 13:12

1 Answer 1


Something somewhere is converting to .jpg. I can tell from some of the pixels and from seeing quite a few jpgs in my time. The jpg may be embedded in a pdf. If you're compiling to pdf, at some point there's a conversion step that not only converts vector to raster graphics, but over-compresses them. My matlab (R2019a) seems to generate raster histograms in .eps files, but not to compress them this badly, though they're not pretty. -dpdf gives me vector graphics and -dpng gives me clean rasters without the jpg artefacts.

I happened to have a matlab window open, and your print statement produces a nice sharp (vector) image. print -dpdf figure1 does too, but that would need cropping -dsvg gives a nice vector graphic with very similar borders to the .eps. That can then be imported into pdflatex using the svg package or converted using inkscape.

When compiling directly to pdf, you're probably using epstopdf or ps2pdf behind the scenes; this in turn uses ghostscript. Some of the ghostscript options affect the compression of the output, and these can be configured by using epstopdf explicitly.

  • I am not a latex expert. I used PDFLaTeX to compile it. Whats confusing to me, is the fact that the graph plots are vector images and the histos not..
    – Playergod
    Oct 7, 2019 at 13:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .