Thread Subject: quiver

Subject: quiver

From: Merce Casas Prat

Date: 27 Oct, 2009 13:20:24

Message: 1 of 2

Hi,

I have a question about quiver function in Matlab. If you plot a vector field (e.g wind) with a certain resolution and then you plot in the same figure a second wind field with a higher resolution, these two fields are plotted in a different scale (in order not to overlap, etc.). The (my) problem is: the function quiver autoscales the vectors and then (optionally) applies a scale factor (defined by the user). If you deactivate the autoscaling (setting scale=0) then you cannot choose any scale. Do you know how to control exactly the scale of the vector without any previous autoscaling (so I will be able to have a plot with 2 wind fields in the same scale)? And do you know any simple way to insert a legend in a quiver plot (i.e. a legend with, for example, an unitary horizontal vector)

Thanks

Merc

Subject: quiver

From: David Hannasch

Date: 20 Nov, 2009 22:49:19

Message: 2 of 2

Hi,
I have the same problem. I'm plotting six wind velocity fields that need to be correctly scaled to each other. I don't know how to prevent quiver from autoscaling, but I found a workaround that allows two graphs in the same figure to scale `correctly':
    stretch = mean(mean(magnitude) )*arrowScale;
    h = quiver(xcoord, ycoord, uvel, vvel, stretch);
arrowScale is the same for all plots. You can set it to whatever value makes the plots visible (1000, 0.001, etc).
It's quick and dirty, but it produces a figure that makes visual sense. If you have a graph and then the same graph with all the magnitudes doubled, then the arrows will come out the right length.
To apply the same idea to your situation, if the second resolution is twice the first (for example), the autoscaling will make arrows half as long, so you'll need to stretch them back by a factor of two. Something like this might work:
    stretch = (1/gridScale)*arrowScale;

Hope that helps,
David

"Merce Casas Prat" <merce.casas@upc.edu> wrote in message <hc6s2o$jvl$1@fred.mathworks.com>...
> Hi,
>
> I have a question about quiver function in Matlab. If you plot a vector field (e.g wind) with a certain resolution and then you plot in the same figure a second wind field with a higher resolution, these two fields are plotted in a different scale (in order not to overlap, etc.). The (my) problem is: the function quiver autoscales the vectors and then (optionally) applies a scale factor (defined by the user). If you deactivate the autoscaling (setting scale=0) then you cannot choose any scale. Do you know how to control exactly the scale of the vector without any previous autoscaling (so I will be able to have a plot with 2 wind fields in the same scale)? And do you know any simple way to insert a legend in a quiver plot (i.e. a legend with, for example, an unitary horizontal vector)
>
> Thanks
>
> Merc

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
scaling David Hannasch 20 Nov, 2009 17:54:13
quiver David Hannasch 20 Nov, 2009 17:54:13
quiver Merce Casas Prat 27 Oct, 2009 09:24:06
rssFeed for this Thread

Contact us at files@mathworks.com