5.0

5.0 | 3 ratings Rate this file 117 downloads (last 30 days) File Size: 13.3 KB File ID: #17582

ncquiverref

by Andrew Roberts

 

18 Nov 2007 (Updated 22 Jan 2009)

Code covered by BSD License  

Quiver (vector) with a reference vector or color code on map or Cartesian axes.

Download Now | Watch this File

File Information
Description

This function is a substitute for the standard versions of quiver and quiverm available using a vanilla release of matlab. This version assumes a 2D vector field is being plotted using a gridded flow field from numerical model. It is primarily intended for Earth System Model analysis.

The function enables the scaling of vectors according to a reference vector plotted in the lower right hand corner of the plot axes. The function works for both map and Cartesian axes and allows the color of vectors to be changed.

If a reference value is not provided, the reference value is calculated by rounding the median or maximum magnitude of the quiver vectors. Scaling of vectors still occurs even if the reference vector plotting is switched off. This enables different subplots to share identical scaling so that the relative magnitude of vectors can be compared between subplots (provided they share the same grid).

The function also includes the ability to plot color vectors, all of equal length but color coded according to their magnitude. In this case, a colorbar is provided, complete with units, and no scaling vector is plotted.

Vectors are centered on the grid points they represent, rather than the tail of the arrow being positioned on the grid point as is the case for the vanila Matlab quiver and quiverm versions.

Required Products Mapping Toolbox
MATLAB release MATLAB 7.6 (R2008a)
Zip File Content  
Other Files license.txt,
ncquiverref.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
02 Jul 2009 Ibrahim M

This is genius!

For it to work in multiple colors, you make sure your x and y are produced with/as meshgrid. Also specify your colors according to your choice of colorbar. Eg if your caxis ([15 30]) for SST, then you should have the function as:

ncquiverref(x,y,xx,yy, 'DegC','mean',0,'col',[15 20 25 30]);

Nice work Andrew!

Thank you very much for sharing!!

Ibrahim

25 Sep 2009 Jason Sippel  
02 Oct 2009 Jason Sippel

Great code! After chatting with the author, I have found that the below addendum is useful for plotting a small subdomian of model output. This would be useful if, for example, you are tracking a tropical cyclone in a Lagrangian system with ilat,flat,ilon, and flon sampled from your model grid based on the number of grid points from the storm center.

If you don't do something similar to this, the physical size of the map frame on the screen may not match from one figure to the next.

Here's the code:

    tightmap
    xlim=get(gca,'xlim');
    ylim=get(gca,'ylim');
    
   cutfactor = 1.3;
   xcenter=mean(xlim);
   xoffset=diff(xlim)/2;
   ycenter=mean(ylim);
   yoffset=diff(ylim)/2;
   set(gca,'Xlim',[xcenter-cutfactor*xoffset xcenter+cutfactor*xoffset]);
   set(gca,'Ylim',[ycenter-cutfactor*yoffset ycenter+cutfactor*yoffset]);

Please login to add a comment or rating.
Updates
21 Jan 2009

This is a complete rewrite of the originally posted function. Vectors are generated within this function rather than using quiver and quiverm, are now centered on the grid points, and have the ability to be color coded according to their magnitude.

22 Jan 2009

This function is a complete rewrite of the originally submitted file.

Tag Activity for this File
Tag Applied By Date/Time
quiver Andrew Roberts 22 Oct 2008 09:35:53
reference vector Andrew Roberts 22 Oct 2008 09:35:53
legend Andrew Roberts 22 Oct 2008 09:35:53
earth sciences Andrew Roberts 22 Oct 2008 09:35:53
general Andrew Roberts 22 Oct 2008 09:35:53
color vector Andrew Roberts 21 Jan 2009 17:12:16
earth science Andrew Roberts 21 Jan 2009 17:12:16
oceanography Andrew Roberts 21 Jan 2009 17:12:16
meteorology Andrew Roberts 21 Jan 2009 17:12:16
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com