comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Backlogged question: Drawing vector fields with same scaling in New Graphics
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Backlogged question: Drawing vector fields with same scaling in New Graphics [message #92274 is a reply to message #92230] Mon, 09 November 2015 09:20 Go to previous messageGo to previous message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
On Monday, November 2, 2015 at 7:02:11 PM UTC-7, tianhuachengyue wrote:
> This is an unsolved problem about the vector() function in IDL. Gordon used to post this question on the site:
> http://compgroups.net/comp.lang.idl-pvwave/drawing-vector-fi elds-with-new-graphics/2090071
>
> But actually it wasn't quite solved:
> Is there a way to plot (using New Graphics) two different vector fields on the same set of axes such that the vector fields have the same scaling? Below is a minimal working program. What I want (and sort of expect) is that the v2 vectors be proportionally scaled with respect to the v1 vectors. What I get is that the v2 vectors appear smaller than the v1 vectors, even though they are clearly the same in magnitude.
>
> I followed the suggestions to set v1.length_scale = 2 and
> vmag = mean(sqrt(vx^2 + vy^2)),
> then set v2.length_scale = 2. / vmag to try to let v2 have the same scale as v1. But clearly it didn't help... Please see my codes below.
> Anyone can help me out? Thanks!
>
> PRO test_vector
>
> x = [0.,1.,2.]
> y = [0.,0.,0.]
>
> vx = [1.,1.,1.]
> vy = [1.,1.,1.]
> vmag = mean(sqrt(vx^2 + vy^2))
>
> v1 = vector(vx, vy, x, y, $
> XTITLE='X', YTITLE='Y', $
> XRANGE=[-1.,4.], YRANGE=[-1.,4.])
> v1.arrow_thick = 2
> v1.length_scale = 2
>
> x = [1.,2.]
> y = [1.,1.]
> vx = [-1.0,-1.0]
> vy = [-1.0,-1.0]
>
> v2 = vector(vx, vy, x, y, $
> /OVERPLOT, XRANGE=[-1.,4.], YRANGE=[-1.,4.])
> v2.arrow_thick = 2
> v2.length_scale = 2. / vmag
>
> END
>
> Huazeng

Hi Huazeng,

I think you need to scale the second vector by the ratio of the magnitudes. Try this example:

x1 = [0.,1.,2.]
y1 = [0.,0.,0.]
vx1 = [3.,1.,1.]
vy1 = [3.,1.,1.]
vmag1 = max(sqrt(vx1^2 + vy1^2))

x2 = [0.5,1.5]
y2 = [0.,0.]
vx2 = [2.0,1.0]
vy2 = [2.0,1.0]
vmag2 = max(sqrt(vx2^2 + vy2^2))
print, vmag1, vmag2

v1 = vector(vx1, vy1, x1, y1, $
XTITLE='X', YTITLE='Y', $
XRANGE=[-1.,4.], YRANGE=[-1.,4.])
v1.arrow_thick = 2
v1.length_scale = 4

v2 = vector(vx2, vy2, x2, y2, color='red', $
/OVERPLOT, XRANGE=[-1.,4.], YRANGE=[-1.,4.])
v2.arrow_thick = 2
v2.length_scale = 4*vmag2/vmag1


Cheers,
Chris
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: I want to plot the rainfall data on the image.
Next Topic: cgImage trim

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:13:35 PDT 2025

Total time taken to generate the page: 0.00568 seconds