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 Center および MATLAB AnswersVector 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.