How can I do to enable zoom only for a specific axes?

조회 수: 18 (최근 30일)
Giuela
Giuela 2021년 3월 3일
댓글: Giuela 2022년 7월 5일
In my figure I have two axis showing two plots, and another axes, filled by an image,that I use such a 'button'.
The 'button' do something when the mouse pointer is over it and I click.
My problem is that when I set the zoom option for the first (or the second) axes, it works also for the 'button', that is, when i click on the button image, the image zooms.
I've also noticed that when I choose the zoom-in option in the axes toolbar of the first axes, also for the second axes the zoom-in option is selected.
I want to apply the zoom, pan, or rotate options ONLY for the axes I choose; in the attached code I've tried to use the disableDefaultInteractivity function, but without success. Could anyone suggest me how to do?
Thanks

채택된 답변

Steven Lord
Steven Lord 2021년 3월 3일
Call zoom with an output. Call setAllowAxesZoom on that object. See the "Object Functions" section on the documentation page for zoom for more information.
  댓글 수: 2
Giuela
Giuela 2021년 3월 4일
But I when I click on the zoom icon of the axes toolbar I don't call explicitly the 'zoom' function, how can I do what you suggest me? Can you show it in my example, please?
Thanks
Giuela
Giuela 2021년 3월 4일
I thought that was enough to enabe the axes toolbar for the axes I don't want to zoom or pan it, but it's not true, so I guess the axis toolbars don't operate only for the axes' owner, but they work for ALL the figure's axes.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Marcel Goldschen-Ohm
Marcel Goldschen-Ohm 2022년 7월 5일
The above answer does not work for me in R2022a. Attempting to call setAllowAxesZoom produces the error message "Unrecognized function or variable 'setAllowAxesZoom'." despite the fact that this function is still in the docs. Instead, I solved this by using the zoom handle's ButtonDownFilter. This seems like a better solution anyway as it gives the option of disabling zoom based on event details, not just the axes handle as I show below.
z = zoom(gcf);
z.Enable = 'on';
z.ButtonDownFilter = @(ax,evt) zoomFilter(ax,evt);
arrayOfAxesHandlesForWhichZoomShouldBeDisabled = [ax1, ax2, ax3];
function isZoomSupressed = zoomFilter(ax,evt)
isZoomSupressed = any(arrayOfAxesHandlesForWhichZoomShouldBeDisabled == ax);
end

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by