Save overlaying markers of plot in right order to pdf

2 ビュー (過去 30 日間)
Fa
Fa 2021 年 9 月 17 日
回答済み: Abhinaya Kennedy 2024 年 5 月 8 日
Hi guys,
i sometimes plot marker over each other to get a certain visual effect.
For example, if i want to visualize traffic cones from the "top view", you would see the outer square of the traffic cone and then two inner circles inside. I plot them the following way:
plot(conesX,conesY,'-s','MarkerEdgeColor',[1 0.5 0],'MarkerFaceColor',[1 0.5 0]);
plot(conesX,conesY,'-mo','MarkerEdgeColor',[1 1 1],'MarkerFaceColor',[1 0.5 0]);
If i plot it, everything looks as intended, but if i save it like that:
print('-dpdf','-fillpage',[path savename,'.pdf']);
Than the markers have a different order in which they are saved. If the Circles are saved first and than the square, in the output .pdf only the square is seen.
On the left side, you can the the result i want to have, but about half of the cones look like the right one.
Does anyone know, what to do?
  1 件のコメント
darova
darova 2021 年 9 月 19 日
Attach the code to produce cone. DId you try surf?

サインインしてコメントする。

回答 (1 件)

Abhinaya Kennedy
Abhinaya Kennedy 2024 年 5 月 8 日
Hi Fa,
Problem: Overlapping markers in PDFs due to plotting order. Circles plotted first might be hidden by subsequently plotted squares.
Solution 1: Using hold on
  1. Plot circles first (using "plot").
  2. Use "hold on" to add squares on top (using "plot") ensuring they are drawn over the circles.
Solution 2: Using Patch Objects
  1. Create separate patch objects for squares (using "patch" with rectangle function) and circles (using "patch" with circle function, not shown but assumed available).
  2. Customize their properties (color, size).
  3. Use "hold on" and "patch" to control plotting order (squares over circles).
Choose the method that best suits your needs for simplicity or control over object appearance.

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by