add min and max data tips for multiple lines.

14 ビュー (過去 30 日間)
Matin jaberi
Matin jaberi 2022 年 8 月 11 日
回答済み: RAGHUNATHRAJU DASHARATHA 2022 年 9 月 28 日
Hi All,
I have following 8 plots in a same graph and i need to find a min and max data tips for each plot. I have tried different scripts but no luck. any help is appraciated.

回答 (1 件)

RAGHUNATHRAJU DASHARATHA
RAGHUNATHRAJU DASHARATHA 2022 年 9 月 28 日
As per my understanding you want to add min and max data tips for multiple lines.
I will try to explain it for a single line plot using an example below
x = linspace(1,10,10);
y = 2.*x;
[max_val,maxindex] = max(y);
[min_val,minindex]=min(y);
h =figure; hPlot = plot(x,y);
cursorMode = datacursormode(h);
MaxDatatip = cursorMode.createDatatip(hPlot);
MinDatatip= cursorMode.createDatatip(hPlot);
maxpos = [x(maxindex) y(maxindex)];
minpos=[x(minindex) y(minindex) ];
set(MaxDatatip, 'Position', maxpos)
set(MinDatatip, 'Position', minpos)
updateDataCursors(cursorMode);
For any further information you can go through the link

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by