plotting with text display
1 次查看(过去 30 天)
显示 更早的评论
I have a multi day graph, that I must present in 12 hour blocks.
Currently, my code creates the graph, labels the graph, and places several annotations on the graph with the text function at the appropriate places. Then the code continues on to "parse" the figure into the 12 hour intervals by setting the x-lim in a for loop.
Everything works fine and dandy except for the text annotations. These things are carried over from one part to another and end up outside a particular parsed graph. For example, if there was an annotation at the end of part 1 of the graph, it would show up again in part 2, except it would outside the axis lines.
does anyone have any clever suggestions as to how to get rid of the phantom annotations on the parts of the graph where they don't belong?
Thanks in advanced!
0 个评论
采纳的回答
Image Analyst
2012-6-9
I guess you'd have to capture the handles and location of each text object as you place it, and when it comes time to show interval "n" of the graph, you'd set the visible property to off of all the text handles that are not supposed to be shown when you're showing that interval.
hText1 = text(x1, y1, 'blah');
textHandles(1).handle = hText1;
textHandles(1).x = x1;
and so on for all the text controls you create. Later when you're showing an interval:
% Loop over all text controls, either showing or hiding depending
% on whether it is located inside interval "n" or not.
for k = 1 : length(textHandles)
if textHandles(k).x > currentX1Interval && textHandles(k).x < currentX2Interval
% It is supposed to show.
set(textHandles(1).handle, 'visible', 'on');
else
% It is not supposed to show.
set(textHandles(1).handle, 'visible', 'off');
end
end
where currentX1Interval to currentX2Interval define the x range of the interval you want to show at that time.
2 个评论
Walter Roberson
2012-6-12
hText1 = text(x1, y1, 'blah');
xyz = get(hText1, 'Position');
x = xyz(1); y = xyz(2);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!