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

版本 2.0 (4.7 KB) 作者: Jonas Krimmer
Implements the MATLAB given quiver/quiver3 function adding a color coding depending on magnitude
3.7K 次下载
更新时间 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.