Toolbar zoom button increases size of map instead of zooming in

7 ビュー (過去 30 日間)
Michael
Michael 2011 年 7 月 19 日
回答済み: HANS 2018 年 1 月 25 日
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

回答 (6 件)

Jan
Jan 2011 年 7 月 19 日
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 2011 年 7 月 19 日
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 2011 年 7 月 19 日
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 2011 年 7 月 20 日
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 2011 年 7 月 27 日
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 2018 年 1 月 25 日
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

カテゴリ

Help Center および File ExchangeData Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by