Cursor line
显示 更早的评论
Hi,
I've got a figure with several subplots. These subplots are located one under the other one. Then, that I want to do is create a vertical cursor to across all subplots and when I'm going to move this appear the current values of all subplots.
How can I develop this?
thanks
regards
采纳的回答
更多回答(3 个)
Brett Shoelson
2011-2-14
1 个投票
Paulo Silva
2011-2-14
You might find useful tips inside the ginput function
edit ginput
%this function can be found inside ginput
set(fig,'pointer','fullcrosshair'); %horizontal and vertical cursor lines
9 个评论
Mtlb Usr
2011-2-14
Paulo Silva
2011-2-14
for the cursor lines you just need
set(fig,'pointer','fullcrosshair');
fig is the handle for the figure, you can use gcf instead of fig (fig=figure), gcf give the handle of the current figure
for the cursor position inside the figure you can do
get(gcf,'currentpoint')
for the cursor position inside an axis you can use the ginput, it will give you x,y and the button pressed, that's why I told you to look at the ginput code.
Mtlb Usr
2011-2-14
Paulo Silva
2011-2-14
Here's one example, it allows you to mark points of several subplots, the coordinates and button pressed is shown on the command line.
subplot(311)
hold on
subplot(312)
hold on
subplot(313)
hold on
but=1;
while ((but==1))
[x,y,but]=ginput(1)
plot(x,y,'*')
end
Paulo Silva
2011-2-14
Another version, now the subplots have different and fixed limits, also the point only gets marked when you press the mouse left button.
subplot(311)
hold on
axis([0 100 -10 10])
subplot(312)
hold on
axis([-100 100 -20 10])
subplot(313)
hold on
axis([100 200 -10 20])
but=1;
while ((but==1))
[x,y,but]=ginput(1)
if but==1
plot(x,y,'*')
end
end
Paulo Silva
2011-2-14
if you want to save the coordinates pressed
but=1;xv=[];yv=[];
while ((but==1))
[x,y,but]=ginput(1)
if but==1
xv=[xv x];yv=[yv y];
plot(x,y,'*')
end
end
plot(xv,yv) %you can connect the dots marked
Mtlb Usr
2011-2-14
Paulo Silva
2011-2-14
I'm finally understanding but what you want isn't easy, at least for me and my basic matlab skills, maybe someone with more experience might help you.
Here's some websites with info, maybe you can find something useful in them
http://matlab.wikia.com/wiki/MATLAB_Wiki
http://undocumentedmatlab.com
Mtlb Usr
2011-2-15
类别
在 帮助中心 和 File Exchange 中查找有关 Data Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!