ginput, several curves in one plot
9 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!