フィルターのクリア

How to fix the size of markers when drawing in Matlab? Make the marker larger with local magnification instead of being fixed and unchanged.

2 ビュー (過去 30 日間)
I want to use the markers in the picture to represent the drones in the formation. When the canvas shrinks, the size of the markers should decrease accordingly, and when the area is zoomed in, the markers should increase accordingly. But the actual situation is exactly the opposite.
For example, for the following programs, the markers in the left image should be smaller, and the markers in the right image should be larger.
Can you help me? Thank you very much.
%%%
x = [10 20 30 40];
y = [20 10 10 20];
plot(x,y,'g', 'linewidth', 2)
text(x, y, '✤', 'color', 'r', 'fontsize', 20, 'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle');

採用された回答

Voss
Voss 2024 年 5 月 8 日
編集済み: Voss 2024 年 5 月 8 日
Using image objects or patch objects instead of text objects will cause the "markers" to scale appropriately when you zoom in or out.
  3 件のコメント
屹林
屹林 2024 年 5 月 9 日
Thank you very much ! Your suggestion is very useful, and I have tried it according to your guidance and achieved good results.

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

その他の回答 (1 件)

Harsh
Harsh 2024 年 5 月 8 日
Hi,
From what I can gather, you are working with a plot in MATLAB and are unable to change the size of the text ‘’ which you are using as a marker.
Using ‘Normalized’ units should resolve this issue. Here is an example on how you can implement it in your code:
x = [10 20 30 40];
y = [20 10 10 20];
plot(x,y,'g', 'linewidth', 2)
text(x, y, '✤', 'FontUnits', 'Normalized', 'FontSize', 0.1, 'color', 'r', 'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle');
I hope this helps, thanks!
  2 件のコメント
Voss
Voss 2024 年 5 月 8 日
Using FontUnits 'normalized' makes the text font size a fixed fraction of the axes plot box height. Thus the text will resize when the axes height changes, but not when the x- or y-limits change, which I think is the desired behavior.
屹林
屹林 2024 年 5 月 9 日
Thank you very much for your reply. But directly solving my problem,

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

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by