How to "flatten" parts of a MATLAB image (e.g. basemap) to save space when saving as a vector image?

조회 수: 8 (최근 30일)
I often make plots in MATLAB and then save as vector images (eps format) so that I can do further editing if needed in Adobe Illustrator (e.g. adding labels, combining figures, re-sizing parts, etc.).
I am making maps using the Mapping Toolbox and recently added basemaps to the maps. However, when I try to save the figure in vector format as eps, the resulting eps is not actually a vector figure. If I try to change the rendering to manual (painters vector format), then MATLAB begins to lag horribly and I can't even save the figure as it just seems to hang forever.
I don't need the basemap to be vector format, I only need the plotted elements to be vector format. Is there a way to flatten the basemap in MATLAB to avoid this problem?
One option is that I could save the basemap as a PNG and then save the plotted elements as EPS and then assemble it all in Adobe, but that seems a bit clunky.
Example script below
worldmap([40 40.8],[-115 -114]);
%Load basemap
[A,RA,attribA] = readBasemapImage("streets",[40 40.8],[-115 -114]);
[xGrid,yGrid] = worldGrid(RA);
[latGrid,lonGrid] = projinv(RA.ProjectedCRS,xGrid,yGrid);
%Plot basemap: This part of the plot I don't need in vector format
geoshow(latGrid,lonGrid,A)
%Plot other stuff: I want these elements in vector format
plotm(40.5,-114.5,'sk','MarkerFaceColor','m','MarkerSize',20)

답변 (1개)

Umar
Umar 2024년 6월 21일
To flatten the basemap in MATLAB and save only the plotted elements in vector format, you can achieve this by separating the basemap from the plotted elements during the saving process. One approach is to save the basemap as a PNG image and the plotted elements as EPS. Then, you can combine them in Adobe Illustrator. This method ensures that only the plotted elements are saved in vector format while maintaining the quality of the basemap.
Here is an example script demonstrating this approach:
  댓글 수: 1
DGM
DGM 2024년 6월 21일
Your "example script" was not an example script at all. It was an unformatted copy of OP's original code, but you changed the comments for no meaningful purpose. I deleted it, because it is spam.
If you don't have any code to post, don't post fake examples in an attempt to pretend that you're helping. If you do have code, format it.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by