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

version 2.0 (4.74 KB) by Jonas Krimmer
Implements the MATLAB given quiver/quiver3 function adding a color coding depending on magnitude

3K Downloads

Updated 2 Nov 2021

View License

%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.
%

Cite As

Jonas Krimmer (2022). 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. Retrieved .

MATLAB Release Compatibility
Created with R2019b
Compatible with R2019b to R2021a
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: Quiverc

Community Treasure Hunt

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

Start Hunting!