4.0 | 1 rating Rate this file 41 Downloads (last 30 days) File Size: 6.25 KB File ID: #40224
image thumbnail



Melissa Day


11 Feb 2013 (Updated )

Generates a quiver plot colored according to vector magnitude and/or user specified axis boundaries.

| Watch this File

File Information

quiverwcolorbar adds functionality to the original quiver function by assigning color to the arrows according to the vector magnitude. The corresponding colorbar spans the minimum and maximum values of the dataset or can be specified by the user. Any changes to the colorbar boundaries change the vector colors accordingly.

      quiverwcolorbar(x,y,u,v,scale,'bounds',[colormin colormax])

      x, y: Vector locations
      u, v: Vector directions (East-West, North-South)
      scale: Scalar value to set vector lengths
      'bounds': Optional setting to specify colorbar axis minimum and maximum values

      x = rand(1,50).*100;
      y = rand(1,50).*100;
      u = rand(1,50) .* 10;
      v = rand(1,50) .* 10;
      scale = 0;
      figure; quiverwcolorbar(x',y',u',v',scale); %compare to:
      figure; quiverwcolorbar(x',y',u',v',scale,'bounds',[0 10]);


Quiver2.M V1.2 (Nov 2009), Quiverc, Quiverc2wcmap, and Vfield Color inspired this file.

This file inspired Quivermc.

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
31 Oct 2014 Simon


In Matlab 2014a this gives me an error:

Error using set
Bad property value found.
Object Name: axes
Property Name: 'CLim'
Values must be increasing and non-NaN.

Error in caxis (line 79)

Error in quiverwcolorbar (line 185)
caxis([colormin colormax])

It seems to be fixed by adding transposes to line 114, so that line 114 should read:

xyuvvrNN = [x(nonNaNind)',y(nonNaNind)',u(nonNaNind)',v(nonNaNind)',vr(nonNaNind)'];

Comment only
24 May 2013 sundar


Thanks for the quick reply.
I just figured out that when I use imagesc instead of imshow it works fine.

hold on

This works good.

24 May 2013 Melissa Day

Melissa Day

sundar, I'm not familiar with imshow, but the velocity coloring and the colorbar are not linked in this program quite like they are normally, which might be an issue. When I use imshow(quiverwcolormap(x',y',u',v',scale,'bounds',[0 10]),jet) with the data from the example I posted, it looks all right though, but that might not be your problem. Normally when I call this program to plot over another image I just use "hold on". Sorry I can't be of more help - I hope you figure it out!

Comment only
24 May 2013 sundar


When I use quiverwcolorbar, I get a very nice colored velocity field from blue to red, using the jet colormap. My velocity range is between 0 and 13 um/min.
When I use imshow to display my image and then call this function, the colorbar is totally weird and it is only blue in color (ranging from 0 to 13 um/min) even though the velocities are colored blue to red.

I do not know what I should change?

Any help will be awesome.

Comment only
24 Apr 2013 Melissa Day

Melissa Day

FYI to everyone, I had a similar problem with http://www.mathworks.com/matlabcentral/fileexchange/7180-quiverc2wcmap and had to add "view([0,-90]);" after I called the plot for it to look right (after doing a clear all), so if anyone is having trouble with this maybe playing with the view will help.

Comment only
17 Apr 2013 Travis Miles

Travis Miles

For some reason this is flipping my y-axis and image from increasing to decreasing...

Comment only
12 Feb 2013
12 Feb 2013

Fixed some typos, added bit in case min(xyuvvrNNs) < colormin

12 Feb 2013

changed spacing in description

14 Feb 2013

Fixed some typos, added bit in case min(xyuvvrNNs) < colormin

24 May 2013

Minor typo fixes

Contact us