Is it possible to put a symbol next to textbox in graph.

17 ビュー (過去 30 日間)
Eirikur Bernharðsson
Eirikur Bernharðsson 2020 年 3 月 12 日
コメント済み: Raunak Gupta 2020 年 3 月 16 日
The code for the textbox.
txt = sprintf(['ResFreq: ',...
num2str(xy(1)), ' Hz' ]);
txtbox = annotation('textbox', [.6 .33 .1 .1], 'String', ...
[ txt ]);
set(txtbox,'BackgroundColor','red')
set(txtbox,'FaceAlpha',0.2)
set(txtbox,'LineWidth',1)
Here I have a picture of my graph.
I want to place the same triangle inside the textbox.

採用された回答

Raunak Gupta
Raunak Gupta 2020 年 3 月 16 日
Hi,
Adding figure or geometric shape is not directly supported in annotation, the geometric object should be written in the text format which can be done using Latex. So, while creating the text string for the textbox, triangle object can be added in Latex format and 'Interpreter' property of annotation object can be set to 'latex' for it to print properly. Below example can help recreating the same. I am assuming the intersection point is plotted seperately with the triangle icon.
txt = strcat('$\triangle$',sprintf([' ResFreq: ',num2str(50), ' Hz']));
txtbox = annotation('textbox', [.6 .33 .1 .1], 'String', ...
txt);
set(txtbox,'Interpreter','latex')
set(txtbox,'BackgroundColor','red')
set(txtbox,'FaceAlpha',0.2)
set(txtbox,'LineWidth',1)
Hope it helps.
  2 件のコメント
Eirikur Bernharðsson
Eirikur Bernharðsson 2020 年 3 月 16 日
Yes thank you this helped, although I would have liked if the triangle was red if that's possible?
Raunak Gupta
Raunak Gupta 2020 年 3 月 16 日
Hi Since the triangle is actually a text object and not a graphic but you can change the text colour in the textbox property. In that filling the color in triangle may not be possible. Other solution might be using legend in plotting the single intersecting triangle as point on the graph if other lines legend are not required. Hope this helps.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpline Postprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by