ginput, several curves in one plot

9 ビュー (過去 30 日間)
kenoz
kenoz 2019 年 3 月 9 日
コメント済み: kenoz 2019 年 3 月 12 日
Hi
So i have a 'ginput' command that produces a spectrum of a spot in an image. How do i plot all the points I select in the same graph, so that i can compare multiple spectra readily, please?
Thanks for the help

回答 (1 件)

Image Analyst
Image Analyst 2019 年 3 月 9 日
Use plot and hold:
plot(spectralCurve1, '-', 'LineWidth', 2);
hold on;
plot(spectralCurve2, '-', 'LineWidth', 2);
plot(spectralCurve3, '-', 'LineWidth', 2);
etc.
  3 件のコメント
Image Analyst
Image Analyst 2019 年 3 月 11 日
No it didn't make it easier. For one, put all that squeeze stuff before the plot to make a single vector, and put the xlabel and ylabel on separate lines.
Then, I see no reason why you can't, in a loop, just put hold on, and plot your other curves that you got from other clicks. You didn't explain why it did not work. I'd do something like
for k = 1 : numCurves
figure(1) % Move to the image figure.
uiwait(helpdlg('Click on a point'));
(x, y) = ginput()
thisSpectrum = ......squeeze(.......
figure(2) % Move over to the plotting figure.
plot(thisSpectrum.......
hold on;
end
grid on;
Also, your badly-named a and b caused you to flip the rows and columns. a is x which is columns, so it comes second. In other words, it's not imageStack(ceil(a),ceil(b),:), it should really be imageStack(ceil(b),ceil(a),:). An all too common beginner's mistake, so you're not the only one.
kenoz
kenoz 2019 年 3 月 12 日
Thank you very much.
It worked.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by