ginput, several curves in one plot
8 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Image Analyst
on 9 Mar 2019
Use plot and hold:
plot(spectralCurve1, '-', 'LineWidth', 2);
hold on;
plot(spectralCurve2, '-', 'LineWidth', 2);
plot(spectralCurve3, '-', 'LineWidth', 2);
etc.
3 Comments
Image Analyst
on 11 Mar 2019
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.
See Also
Categories
Find more on Data Exploration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!