Some figures not saving as vector graphics (.svg)
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hi,
I ran into a strange problem. I'm trying to save figures in vector format to process in Adobe Illustrator. I make numerous of these plots using one script and in many cases the output to vector graphics using the .svg format works fine. Some figures, made by the same script and apart from the specific datapoints indistinguishable from other figures, do not export as proper vector graphics. In those cases I can open the output .svg file in Illustrator but the image is basically flat; i.e. I can not isolate individual elements for editing.
I have attached two figures extracted at the exact point in the script where the data is added that causes it to not save properly. I plot datapoints on a trial-trial basis, adding data from one trial, then the data from the next trial etc. Until a particular trial I can save the figure as a proper vector graphic .svg file (attached as Fig1Vector.fig). When data from the next trial is added, the output .svg file only contains a flattened image (attached as Fig2NotVector.fig).
I've been looking for differences between the two figures but I have exhausted my ideas on what could be at cause. Do any of you have any idea what could be going wrong here or any suggestions to do a successful vector image export?
Thanks in advance.
Best, Paul
採用された回答
I figured out what the problem was. After a certain maximum of elements in the picture, Matlab's auto-renderer setting switches from using the -painters renderer to the -opengl renderer. Manually forcing the -painters renderer restores proper vector graphics output.
[2023 update] See Martin's helpful reply to this answer for the syntax to trigger the correct behavior in different Matlab versions.
16 件のコメント
mohammad vakilinejad
2017 年 11 月 8 日
Well, this helped me a lot in restoring vector format. But I'm facing another problem: All my dashed lines turn into straight lines after this setup.
TheStranger
2020 年 4 月 10 日
Thank you, Paul, from 2020 :)
Mengxue Cao
2020 年 8 月 8 日
Thank you Paul! You save my day!
Zachary
2020 年 12 月 16 日
Thank you, Xinxing from 2020. Save my life:)
germ
2020 年 12 月 17 日
Thanks!
Victor Richard Selve
2020 年 12 月 31 日
First of all thank you very much, also side note setting the option in the Export Setup window does not seem to do anything, but setting the flag in the print funtion works.
shuang zhou
2021 年 11 月 18 日
Yes, print function works well, please use print('-painters','-dsvg','myVectorFile') or print('-painters','-depsc','myVectorFile')
Veldon-James Laurie
2022 年 7 月 5 日
thank you in 2022
Ji Hoon Jeong
2022 年 8 月 12 日
Thank you in 2022
Chung-Hsuan Tung
2022 年 9 月 16 日
Thank you in 2022. I spent so many hours trying to figure out why and you saved my weekend!
Chinmayee L M
2023 年 1 月 21 日
Ran into the same issue. Where do you enable that manually?
Paul
2023 年 1 月 21 日
編集済み: Walter Roberson
2023 年 11 月 20 日
By setting the 'renderer' property of the figure. https://nl.mathworks.com/help/matlab/ref/matlab.ui.figure-properties.html#buiwuyk-1-Renderer
Martin Jendryka
2023 年 9 月 12 日
編集済み: Walter Roberson
2023 年 11 月 20 日
before Matlab 2021
print(gcf,'-painter','-dsvg',[fname,'.svg']) % svg
print(gcf,'-painter','-dpdf',[fname,'.pdf']) % pdf
from Matlab 2021
print(gcf,'-vector','-dsvg',[fname,'.svg']) % svg
print(gcf,'-vector','-dpdf',[fname,'.pdf']) % pdf
Paul
2023 年 9 月 12 日
Thanks Martin! I have edited my answer to refer to your addition.
Walter Roberson
2023 年 11 月 20 日
Omid Elmi https://www.mathworks.com/matlabcentral/profile/authors/10253847 comments to @Martin Jendryka :
Thanks, Martin!!!
Nikolai Kozlov
2026 年 3 月 17 日
Please check your syntax. It should be '-painters' with an s, AFAIK.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
