I’d like to zoom in on a plot using a script. I’m only interested in horizontally constrained zooming. So I’d like to do something like
p = plot(myData);
z = zoom;
set(z, 'ZoomInToPoints' , [50 100]);
or
p = plot(myData);
myZoom([50, 100]);
So either of these functions would zoom into a plot like when you zoom in with the magnifying glass tool. I only specify two points because I only want to zoom horizontally.
Note, I’ve already tried to use xlim for this. While it works, it doesn’t let me use the command text on my plots, which I need.
Calls to
textwill fix the text at a specific set of coordinates on the graph. Have you tried updating these after calling xlim?EDIT: You can always adjust the text position:
Not pretty, but it should work. If you have more than one annotation per axes or axes per figure, you can always throw the above code in a loop.