Keeping non-vector elements in a vector graph export

3 次查看(过去 30 天)
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.

回答(1 个)

Kartik
Kartik 2023-4-18
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:

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by