ginput, several curves in one plot

조회 수: 8 (최근 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 CenterFile Exchange에서 Data Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by