Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to synchronously adjust the viewing Angle of multiple subgraphs by Matlab

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to synchronously adjust the perspective of multiple subgraphs in Matlab". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to synchronously adjust the perspective of multiple sub-images by Matlab".

Problem to be solved: I want to rotate one of the AXES's viewing angles while the other AXES rotates with the same view.

The following first explains how to use the function, and gives the complete code of the function at the end:

DEMO1 changes coordinate range and viewing angle at the same time

Refer to the utility function directly at the end of the code and add a line:

SCR ()

You can adjust the coordinate range and viewing angle at the same time by adjusting a certain coordinate region. The example code is as follows:

% demo1.m% @ author: slandarer [XMagi Y] = meshgrid; Z=sin (X) + cos (Y);% coordinate region 1 drawing subplot (1Magi 2 Magazine 1) surf (Xmemy Ypenz) colormap (gca,summer)% coordinate region 2 drawing subplot (1Magne2) surf (XMague YMagazi) colormap (gca,winter)% apply coordinate region synchronous rotation function SCR ()

DEMO2 only changes the perspective at the same time.

Because sometimes the coordinate range of the drawing is really different, if you want to change the angle of view but not change the coordinate range, you can add it at the end:

SCR ('ucLim')

% demo2.m% @ author: slandarer [XMagi Y] = meshgrid; Z=sin (X) + cos (Y);% coordinate area 1 drawing subplot (1Magazine 2) colormap (gca,summer)% coordinate region 2 drawing subplot (1Magne2) surf (peaks) colormap (gca,winter)% apply coordinate region synchronous rotation function% only change the viewing angle but not the axis range SCR ('ucLim')

More subgraphs of DEMO3

No matter how many sub-images are followed by the line that is added as usual, is it easy to use Gaga:

% demo3.m% @ author: slandarer% draws 6 pictures: Machia2 * Numb3 * for Manglu 1 for nong1 subplot N subplot (MMagneN + (Mmer1) * N) hold on Grid on scatter3 (rand ([5jue 1]), rand ([5jue 1]), rand ([5jue 1]) 'filled') endend% applies coordinate area synchronous rotation function% only changes the viewing angle but does not change the axis range SCR (' ucLim') tool function complete code function SCR (varargin)% @ author: slandarer% @ official account: slandarer essay% @ Zhihu: hikari% @ CSDN: slandarer%% look forward to your attention! help SCR% if you do not want to output [author information], please delete this line of uchangeLim=false If nargin > 0 if ischar (varargin {1}) & & strcmp (varargin {1}, 'ucLim') uchangeLim=true;fig=gcf; elseif strcmp (get (varargin {1},' type'), 'figure') fig=varargin {1}; endelse fig=gcf;endif nargin > 1&&ischar (varargin {1}) & & strcmp (varargin {1},' ucLim') uchangeLim=true;end% is axes serial number ch=fig.Children;for i=1:length (ch) ch (I) .UserData = iShift endfig.CurrentAxesroomch (end) IsClicking=false;set (fig,'WindowButtonDownFcn',@bt_down);% set mouse down callback set (fig,'WindowButtonUpFcn',@bt_up);% set mouse release callback set (fig,'WindowButtonMotionFcn',@bt_move);% set mouse movement callback function bt_down (~, ~), isClicking=true;end% mouse down callback function bt_up (~, ~), isClicking=false End% mouse release callback function bt_move (~, ~) if isClicking tempAxes=fig.CurrentAxes;% to get the currently clicked axes tempAxes.UserData; for ii=1:length (ch)% two axes if ch (ii) .UserData ~ = tempAxes.UserData ch (ii) .View=tempAxes.View % Let other axes have the same viewing angle as the clicked axes if ~ uchangeLim ch (ii) .XLim = tempAxes.XLim;% have the same X-axis coordinate range ch (ii). YLim = tempAxes.YLim;% have the same Y-axis coordinate range ch (ii) .ZLim=tempAxes.ZLim % has the same Z-axis coordinate range endendend endendend so far, I believe you have a deeper understanding of "how to synchronously adjust the perspective of multiple subimages by Matlab". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report