Segment of Graph Extraction
3 次查看(过去 30 天)
显示 更早的评论
Can you use any plotting tools to extract a segment of a graph and replot that segment into a new figure or subplot?
0 个评论
采纳的回答
Walter Roberson
2011-6-17
How complex is your scene? The work needed for a patch or surface object is more than the work needed for line graphs.
Gerd's approach has the property of not drawing portions of the graph that would extend beyond the edges. For example if you defined a plot as a straight line between two points and you want to display the middle of that line with the end-points both outside of the window, Gerd's approach would not draw the line at all.
If you have text written on the graph that would be partly inside the sub-area, do you want the fraction of the text displayed?
The easiest approach might be to copyobj() the children of the axes to the new axes, and then set the XLim and YLim properties of the new axes to show only the portion you want.
1 个评论
更多回答(1 个)
Gerd
2011-6-17
Hi Daniel,
I don't know any plotting tool in Matlab but with some lines of code it shouldn't be a problem.
xlimit=get(gca,'XLim');
nearest= min(abs(a-xlimit(1)));
% find index of nearest time value
indexX1 = find(a==xlimit(1)+nearest | a==xlimit(1)-nearest);
nearest= min(abs(a-xlimit(2)));
% find index of nearest time value
indexX2 = find(a==xlimit(2)+nearest | a==xlimit(2)-nearest);
figure;
plot(a(indexX1:indexX2),b(indexX1:indexX2));
First, I would check the XLimits of the current axes and determine the nearest point in the time vector. Then plotting with the new indices. Of course you can also plot in a subplot.
Gerd
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!