Keeping non-vector elements in a vector graph export

3 views (last 30 days)
I am using Planet3D to generate some plots of transfers around the Solar System. I have figures such as this:
When I export them using
exportgraphics(gca,'name.pdf','ContentType','vector')
I get a pdf file of 90MB that is of course excessive. This is due to the high-resolution surfaces used by the Planet3D function. The alternative is to export it as a non-vector graphic (jpg or png), but I would like to keep the vector nature of the axes and the legend in order to integrate the figure text in my document. I wonder if there might be a way to tell the exportgraphics function to generate the figure with everything as a vector except for the planet objetcs, which can perfectly be rendered in low-resolution and inserted in the resulting pdf.

Answers (1)

Kartik
Kartik on 18 Apr 2023
Hi,
You can export the plot as a vector graphic while using low-resolution planet objects by setting the "Renderer" property of the figure to "Painters". This renderer creates vector graphics and is well-suited for simple graphics such as lines, patches, and text, but does not support high-resolution surface rendering.
Here is an example code that demonstrates this approach:
% Generate plot with Planet3D function
figure
p = Planet3D('Earth','Texture','Natural','Clouds',true);
hold on
% Add other plot elements
plot3(...)
% Set Renderer property to Painters
set(gcf,'Renderer','Painters')
% Export plot as PDF with vector graphics
exportgraphics(gca,'name.pdf','ContentType','vector')
For more information on the "Renderer" property and its options, see the MathWorks documentation:

Categories

Find more on Printing and Saving in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!