plotting with text display
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Image Analyst
el 9 de Jun. de 2012
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 comentarios
Walter Roberson
el 12 de Jun. de 2012
hText1 = text(x1, y1, 'blah');
xyz = get(hText1, 'Position');
x = xyz(1); y = xyz(2);
Más respuestas (0)
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!