MATLAB Answers


How to best include Matlab figure with transparency in a LaTeX document?

Asked by Johannes Pfeifer on 30 Aug 2019
Latest activity Commented on by Johannes Pfeifer on 3 Sep 2019
Usually, the recommended way to include figures in LaTeX is via eps as discussed in This has the big advantage that eps stores the bounding boxes so that LaTeX will crop the figure automatically to remove whitespace.
But now I have a figure with alpha transparency and such transparency is not supported by eps. Of course I could export the figure into a PDF, but then I have to manually crop it before including it in LaTeX. So is there a better pipeline available?


Sign in to comment.

1 Answer

Answer by Subhadeep Koley on 3 Sep 2019
 Accepted Answer

In MATLAB R2019a you can save EPS with alpha transparency.
print('yourTransparentImage','-depsc');% place this code after the figure generation code
Find the attached zip file having transparent EPS file generated using this code. Also see the attached PDF with transparent EPS generated by LaTeX.
Otherwise, you can find a custom function to exports figures to a number of vector & bitmap formats here.


Thank you for your answer. But that is not native transparency, as far as I can see ( Importantly, the resulting graphic is not a vector graphic anymore. Zoom in and you will see that the axis tick labels are pixelated and grainy.
You can set the renderer property of the print function to '-painters' If you want to ensure that your output format is a true vector graphics file. The below code might help.
Adding this true vector EPS to your LaTeX document doesn't make the axis tick labels pixelated and grainy (see the attached PDF).
Perfect. That was what I was looking for.

Sign in to comment.