How to best include Matlab figure with transparency in a LaTeX document?
31 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Johannes Pfeifer
le 30 Août 2019
Commenté : Jonas
le 6 Fév 2023
Usually, the recommended way to include figures in LaTeX is via eps as discussed in https://de.mathworks.com/matlabcentral/answers/96084-how-do-i-include-a-matlab-figure-in-a-latex-document. 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?
0 commentaires
Réponse acceptée
Subhadeep Koley
le 3 Sep 2019
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.
5 commentaires
Fred
le 4 Déc 2022
I am having problems with this solution. My plot with an alpha channel assigned is washed out in eps but okay in pdf, but I need the eps for the bounding box. See the attached zip file. The m-file is repeated below.
%%% Test alpha channel
clear vars, close all
x = (0:0.002:1)';
hold on
for ii = 1:100
plot(x,x+0.1*randn(length(x),1),'Color',[0 0 1 0.01])
end
exportgraphics(gca,'TestAlphaPlotEG.eps')
print('TestAlphaPlot.eps','-depsc')
print('TestAlphaPlot.pdf','-dpdf')
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Printing and Saving dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!