Can the arrows of a quiver plot rotate around their mid point?

조회 수: 14 (최근 30일)
KarlHoff
KarlHoff 2018년 1월 18일
댓글: Milan Vala 2023년 1월 26일
I am plotting nematic orientation using quiver plots (without arrowheads). Data is stored as an angle, with values limited to a range of size pi (in my case from 0 to pi). Whenever the orientation passes through 0 (which for nematics is equivalent to pi and therefore a smooth change), the plots look as if there was a small gap or arrows would be overlapping.
The first plot has a kind of 'gap' where theta_nematic jumps from just below pi to just above 0 (viewed in the direction of increasing x coordinate), and where theta_nematic jumps from just above 0 to just below pi in the second plot, the arrows are much closer than in other regions of the plot or even overlapping as shown.
This behaviour is due to the fact that MATLAB puts the tail of a quiver arrow at the position specified by x and y in the call to quiver(x,y,u,v).
For my purpose it would be much better to have the middle point of the arrow located at the position [x,y]. In python's matplotlib, this is achieved with "pivot='mid'", confer the second plot in this matplotlib example.
Does MATLAB have the same functionality for quiver plots, that is quiver arrows rotating around their mid point? The Quiver Series Properties do not contain a pivot or similar.
P.S.: Images were produces with this example code (and slight zooming):
[x,y] = meshgrid(1:100, 1:100);
theta = 0.1*x; %theta = -0.1*x; for the second plot
theta_nematic = mod(theta,pi); %limit the angle to the interval 0 to pi
u=cos(theta_nematic); %for plotting, convert angle into components of a unit vector
v=sin(theta_nematic);
myfig = figure(123);
myquiv= quiver(x,y,u,v);
myquiv.ShowArrowHead = 'off'; %to represent nematic orientation

답변 (1개)

Y.S.
Y.S. 2020년 3월 10일
As far as I can see, quiver does not have the option to rotate about the midpoint. Would be a very useful addition though!
But it can be done manually. The trick is to turn off AutoScaling and then move the quivers to rotate around the midpoint.
This does mean that autoscaling is no longer used.
myfig = figure(123);
clf; hold all;
%%generate data
[x,y] = meshgrid(0:pi/2:9*pi, 0:pi/2:9*pi);
theta = 0.1*x; %theta = -0.1*x; for the second plot
theta_nematic = mod(theta,pi); %limit the angle to the interval 0 to pi
u=cos(theta_nematic); %for plotting, convert angle into components of a unit vector
v=sin(theta_nematic);
%% plot original quiver (rotated about endpoint)
myquiv= quiver(x,y,u,v);
myquiv.ShowArrowHead = 'off'; %to represent nematic orientation
myquiv.AutoScale = 'on'; % turn off autoscaling
myquiv.Color=[0.9 0.9 0.9];
%% plot modified quiver (rotated about midpoint)
% Quiver absolute size
ScaleF=2;
%calculate arrow starting points (when rotated about midpoint)
x_tail = x - ScaleF/2*cos(theta_nematic);
y_tail = y - ScaleF/2*sin(theta_nematic);
% scale quiver accordingly
u=ScaleF*u; %for plotting, convert angle into components of a unit vector
v=ScaleF*v;
myquiv= quiver(x_tail,y_tail,u,v,'b');
myquiv.ShowArrowHead = 'off'; %to represent nematic orientation
myquiv.AutoScale = 'off'; % turn off autoscaling
% plot midpoints
plot(x,y,'.r');
red: x,y points
grey: original quiver rotating about endpoint
blue: quivers rotating about midpoint

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by