Quiver - magnitude-dependent color in 2D and 3D

버전 2.0 (4.74 KB) 작성자: Jonas Krimmer
Implements the MATLAB given quiver/quiver3 function adding a color coding depending on magnitude
다운로드 수: 3.5K
업데이트 날짜: 2021/11/2

라이선스 보기

%quiverC3D creates a 3D quiver plot and adds a color coding. The color coding is
%given by the magnitudes of the component vectors. Large values result in colors
%from the upper end of the used colormap.
%
% INPUT:
% x - array, x components of initial points
% y - array, y components of initial points
% z - array, z components of initial points
% u - array, x components of arrows
% v - array, y components of arrows
% w - array, z components of arrows
% scale - number, if > 0, automatic scaling is used to avoid overlap
% of adjacent arrows. If scale = 0, the scaling is disabled.
% MaxNumArrows - a positive integer (non-integer should work as well)
% number limiting the maximum number of plotted arrows. Since vectors
% of length zero aren't plotted and the matrices are sampled
% uniformly, it's possible that fewer arrows will be visible in the
% end. If MaxNumArrows is not given its value is set to inf.
%
% OUTPUT:
% none
%
% WARNING!: This function might not create arrows with the same length as
% would be obtained using quiver3(x, y, z, u, v, w). I do not know
% whether the scaling method is the same is in quiver3.
%
%
% --------------------------------------------------------------------------------------
%
% EXAMPLE:
% load wind
% quiverC3D(x,y,z,u,v,w,1,1000);
% view(-45,20)
% set(gca, 'Color', 'black');
% axis tight
% axis equal
%
% --------------------------------------------------------------------------------------
%
% See also: QUIVER3, LINESPEC, COLORMAP.
%

인용 양식

Jonas Krimmer (2024). Quiver - magnitude-dependent color in 2D and 3D (https://www.mathworks.com/matlabcentral/fileexchange/58527-quiver-magnitude-dependent-color-in-2d-and-3d), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2019b
R2019b에서 R2021a까지의 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Vector Fields에 대해 자세히 알아보기
도움

받음: Quiverc

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
2.0

Breaking change: Normalization behavior changed. Now, all arrows feature the same length in case of normalization.

1.3

Fixed bug in Matlab 2018b and earlier

1.2

Included option to add a colorbar. Implementation based on the comment by Javier - thank you very much!

1.1.2

- Fixed a bug hindering the maximum calculation required for the coloring in older MATLAB releases.
- Replaced the maximum-determined automatic scaling by an average-based one.

1.1.1

Adjusted compatibility

1.1

Added compatibility with arrays of arbitrary dimensions. This addition is particularly useful for quiverC3D where the arrows can now be characterized by three-dimensional arrays.

1.0.3

From now on: No automatic normalization. In case of normalization, the longest vector will now be plotted with length one.

1.0.2

Function is now more intelligent: Creates grouped quiver plots if arrays contain more elements than the colormap. Enables plotting of thousands of arrows without major issues.

1.0.1

- Fixed a bug where the colormap was assumed to carry a fixed number of 64 colors.
- Fixed a bug in quiverC3D leading to an incorrectly calculated vector magnitude.

1.0.0.0

2016_08_03: Updated description.