Saving a massive graphics object as mixed vector and image file

24 次查看(过去 30 天)
I am trying to save a publication quality version of a very large graphics object (a [19290x1566] spectrogram plotted on loglog axes using surf). I need the text to be in editable vector format per journal requirements, but every approach I can find that theoretically should save a vector image file (and successfully does with a smaller figure) ends up crashing both Matlab and my computer.
I'm noting some details of what I've tried in terms of saving a vector file below for reference, but the only solution I've managed to come up with is to first save the figure as an eps image file and crop it to just the image portion in Adobe Illustrator, then manually delete the surface object and save the empty axes as a vector eps file... then put the two back together in Illustrator. This seems like a right silly solution but I can't find anything better.
Is there any way of saving figures as vector files that preserve axes and text but with the image portion saved as a single raster raster object?
For reference, I'm using Matlab 2023a (but have run into the same problem since at least 2015) and have tried using a range of options with the print function:
print(gcf,'test', '-depsc', '-vector')
I've also tried '-dpdf' and '-dsvg' both with and without the '-vector' option, as well as more complicated approaches like variants of the recommendations provided in both of the following articles/answers:
  1 个评论
David
David 2024-5-16
编辑:David 2024-5-16
It's interesting that exportgraphics does this automatically for certain types of graphs:
imshow(rand(500));
xlabel("Something");
exportgraphics("something.pdf");
gives a raster image of ant wars with a selectable label, so the logic to do this exists, but is not used for graphs that are rasterized due to their size.
I have very little hope this will be implemented in time for my thesis printing, but consider me a +1.

请先登录,再进行评论。

回答(1 个)

Rasmita
Rasmita 2023-6-6
Hi Danica,
It is my understanding that, you want to save the large figure as a vector file that preserves the axes and text, while exporting the image portion as a raster object.
For this you can use the "export_fig" function available on the MATLAB File Exchange. This function is especially suited to exporting figures for use in publications and presentations.
Here are the steps you can follow to export your figure as a vector file with only the image portion saved as a raster object:
  1. Install the "export_fig" function from the MATLAB File Exchange by downloading the package from the below mentioned: https://www.mathworks.com/matlabcentral/fileexchange/23629-export_fig
  2. Add this folder to your path.
  3. Create and configure your figure.
  4. Configure the "export_fig" options for your export as follows:
export_fig('myfigure.pdf','-pdf','-transparent','-r300','-nocrop');
Please refer to the below link for more information on “export_fig”:
You can also refer to below MATLAB Answer to know more on using export_fig” function:
Hope this helps you resolve the query!
  1 个评论
Breno Vincenzo de Almeida
This exports everything in vector format, it doesn't rasterize the image within the axes, while keeping the rest vectorized, as requested in the original post.
exportgraphics does the same.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by