Toolbar zoom button increases size of map instead of zooming in

6 views (last 30 days)
I'm working on someone else's code and running into a problem. A figure is created and two different graphs are placed on it - a map (axesm command) and a x-y graph (axes command). Everything in the map is being drawn correctly to start. When the user selects the zoom button in the toolbar and clicks on the map, though, the entire map increases in size instead of zooming in. And that means it overwrites the x-y graph below it, which I need to be able to see as I'm zooming in.
How can I fix the graph size so that the zoom function really just zooms in? I know I'm not giving enough information here, but I'm not sure how much of the code is relevant and don't want to post a giant code list that's meaningless.
Any help would be greatly appreciated! Thanks so much.
Michael

Answers (6)

Jan
Jan on 19 Jul 2011
The difference between zooming and increasing the size is that for the later the pixels outside the axes rect are not clipped. Therefore I assume, that the Clipping property of the map is disabled in Matlab 2011 for unknown reasons. So please check:
get(ma, 'Clipping')
or whatever is the correct method to get the properties of the underlying image(?) object.

Michael
Michael on 19 Jul 2011
Just a little more information. Here is the relevant code:
handles.map_figure = figure('Name','Map','Units','normalized','Position',[0.01,0.01,0.70,0.50],'MenuBar','none','Toolbar','figure','CloseRequestFcn',{@map_close});
handles.histogram_axes = axes('Units','normalized','Position',[0.1,0.05,0.8,0.20],'Box','on','FontSize',8,'YTick',[],'ButtonDownFcn',{@histogram_press});
handles.map_axes = axes('Units','normalized','Position',[0.05,0.3,0.8,0.7]);
set(gca,'Box','off','Color','none','XColor',get(gcf,'Color'),'YColor',get(gcf,'Color'))
ma = axesm ('mercator','FFaceColor',[1 1 1]);
setm(ma,'MLabelRound',-2,'PLabelRound',-2,'MLabelLocation',20,'PLabelLocation',20,'MLineLocation',20,'PLineLocation',20,'Grid','on','MeridianLabel','on','ParallelLabel','on','Frame','on')
I've tried these lines on two different Matlab2011 installations, the zoom problem occurs (the whole map gets bigger, as opposed to zooming in). However, trying the code on a Matlab2009 installation works fine - the map zooms (the axis labels get a little screwed up, but I can live with that).
Can anyone help me out? I'm really stuck.
Michael

Michael
Michael on 19 Jul 2011
Thanks so much Jan. When I check the property, 'Clipping' is turned on. One thing I noticed is that in Matlab 2009, what actually happens when zooming is that the map is getting clipped to the limits of the underlying figure (created by the second axes command). The grid labels aren't clipped, so they still go all over the place.
In Matlab 2011, the map does not get clipped to the limits of the underlying figure. In fact, when I try to pan I just drag the entire map around the window. Here's a simplified code snip:
figure
axes('Units','normalized','Position',[0.05,0.3,0.8,0.7]);
ma = axesm ('mercator','FFaceColor',[1 1 1]);
setm(ma,'MLabelRound',-2,'PLabelRound',-2,'MLabelLocation',20,'PLabelLocation',20,'MLineLocation',20,'PLineLocation',20,'Grid','on','MeridianLabel','on','ParallelLabel','on','Frame','on')
Any other suggestions? I need to get two different graphs in the same window. If there's a different/better way of doing it, I'd be happy to hear.
Thanks again for your help.
Michael

Michael
Michael on 20 Jul 2011
I installed Matlab 2011 on the computer with 2009, and the program stopped working. So it's definitely an issue with 2011.
Michael

Paul
Paul on 27 Jul 2011
I have a similar problem, (occurs in 2009 and 2010 versions). Problem occurs after setting some axes properties.
Zoom works normally when running the following code segment.
newHandle = figure(numPlots);
plot(X_pos,Y_pos,'r');
hold on;
plot(ord_X,ord_Y,'*');
hold off;
newAxes = get(newHandle,'CurrentAxes');
However, after this line, zoom behavior changes.
set(newAxes,'View',[-90, 90],'YDir','Reverse');
With the new zoom behavior, single left-click does nothing, and boxing an area isn't allowed. To zoom in, you hold the left mouse button and drag up or to the right (down or to the left zooms out). Additionally with the new zoom behavior, sometimes double clicking changes the angle the axes is viewed, and changes zoom back to normal.
Clipping is on, i tried changing the order of the children in the axes, i tried using cameraUpVector rather than using view, and I tried moving the set() after the first plot.
Anyone know how I could either fix zoom, or change the plot orientation without messing up zoom?

HANS
HANS on 25 Jan 2018
I need help in zoom.
After typed "set(newAxes,'View',[-90, 90]);"
then zoom is almost corrupted like single left-click does nothing, and boxing an area isn't allowed. To zoom in, you hold the left mouse button and drag up or to the right (down or to the left zooms out).
The situation is same as thethe last comment before mines above.
Please could anybody help me to fix it ?
Thx, WR

Categories

Find more on Data Exploration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!