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

8 ビュー (過去 30 日間)
Darcy Cordell
Darcy Cordell 2024 年 6 月 20 日
コメント済み: DGM 2024 年 6 月 21 日
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 Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by