Save as SVG not exporting as layers with certain plotting scripts

81 vues (au cours des 30 derniers jours)
Alex Hughes
Alex Hughes le 29 Mar 2022
Modifié(e) : Ernesto Rosas le 9 Août 2023
I have plotted some maps using imagesc and added addition features to the maps using mapshow. When I save this map in .svg format so that I can tweak it in design software it loads the different map elements as editable layers. However, if I use contour to plot contours on the map and then save as an .svg (or .eps) it just saves the whole map as an image which is uneditable. Is this a bug or is there some property I can alter to be able to export the map as editable layers when I apply the contours? Thanks.

Réponse acceptée

Richard Quist
Richard Quist le 30 Avr 2022
Modifié(e) : Richard Quist le 1 Mai 2022
When generating vector formats like SVG, MATLAB uses a heuristic to determine how to export the content. In your case it appears that adding the contour has caused the heuristic to choose to embed the content as an image, rather than as "true" vector content. You can override the heuristic by doing one of the following:
% Assuming fig is the handle to the figure you are trying to save...
% set the figure's Renderer property to 'painters' before saving as EPS/SVG:
set(fig, 'Renderer', 'painters');
% If saving as an EPS file, in R2020a and later, you can use the exportgraphics command and specify the 'ContentType' as 'vector':
exportgraphics(fig, 'output.eps', 'ContentType', 'vector');
% For both EPS and SVG, you can use the print command and include the '-painters' option:
print(fig, 'output.svg', '-painters');
I hope that helps.
  3 commentaires
Sebastián Esteban Ojeda Vásquez
Si fuera un polígamo, te cedería una de mis esposas

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Model Import dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by