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

Home » Public Forums » archive » Re: oplot for plots
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: oplot for plots [message #49803] Fri, 18 August 2006 08:32 Go to next message
Norbert Hahn is currently offline  Norbert Hahn
Messages: 46
Registered: May 2003
Member
"Nic" <nicole_messages@juno.com> wrote:

> It is making lines (how do I get it to plot arrows?), but I think each
> time the for loop runs, it is overwriting the previous loop's plots. I
> want to overplot each new plots to the original surface plot.

You may use arrow in stead of plots. arrow can be called as often as needed
and will add one or more arrows to an existing plot. Unfortunately the
coordinates accepted by arrow are 2D. So you need either transform your
3D data to 2D by calling convert_coord or modify the call to convert_coord
within arrow.pro.

HTH
Norbert
Re: oplot for plots [message #49804 is a reply to message #49803] Fri, 18 August 2006 08:27 Go to previous messageGo to next message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
David Streutker wrote:
> Try this:
>
> plots, [index1,index1], [index2,index2], [0,z[index1,index2]], /t3d
>
> As for the arrows, you may have to make and add your own arrowheads to
> the existing lines.
>

There is the built-in arrow.pro you might want to look at.
Re: oplot for plots [message #49806 is a reply to message #49804] Fri, 18 August 2006 08:07 Go to previous messageGo to next message
David Streutker is currently offline  David Streutker
Messages: 34
Registered: June 2005
Member
Try this:

plots, [index1,index1], [index2,index2], [0,z[index1,index2]], /t3d

As for the arrows, you may have to make and add your own arrowheads to
the existing lines.

-David
arrow.pro to 3-D [message #49877 is a reply to message #49803] Fri, 18 August 2006 17:16 Go to previous message
Nic is currently offline  Nic
Messages: 5
Registered: June 2006
Junior Member
Hi again! I have been trying to convert arrow.pro to 3D. Here's what
I have so far. When I try it out, it compiles. I tested it out and my
output sort of makes sense.

Usage:
Arrow_3d x0, y0, z0, x1, y1, z1

If I input:
> arrow_3d, 100, 200, 0, 200, 200, 0 I get arrow to the right. check
> arrow_3d, 100, 200, 0, 100, 300, 0 I get arrow up. check
> arrow_3d, 100, 200, 0, 100, 200, 300 I get a dot.

Is the dot really an arrow pointing out of the screen in a 2-d plots,
or have I screwed up my modification?

Thank you,
Nic



**********************
PRO ARROW_3D, x0, y0, z0, x1, y1, z1, HSIZE = hsize, COLOR = color,
HTHICK = hthick, $
THICK = thick, DATA = data, NORMALIZED = norm, $
SOLID = solid

COMPILE_OPT idl2

ON_ERROR, 2
; Set up keyword params

if n_elements(thick) eq 0 then thick = 1.
if n_elements(hthick) eq 0 then hthick = thick

;Head size in device units
if n_elements(hsize) eq 0 then arrowsize = !d.x_size/64. * (hthick/2. >
1) $
else arrowsize = float(hsize)
if n_elements(color) eq 0 then color =!P.color
mcost = -.866d ;We use 30 degrees for head angle
sint = .500d
msint = - sint

for i = 0L, n_elements(x0)-1 do begin ;Each vector
if keyword_set(data) then $ ;Convert?
p = convert_coord([x0[i],x1[i]],[y0[i],y1[i],[z0[i],z1[i]]],
/data,/t3d, /to_dev) $
else if keyword_set(norm) then $
p = convert_coord([x0[i],x1[i]],[y0[i],y1[i]],[z0[i],z1[i]] /norm,
/to_dev) $
else p = [[x0[i], y0[i], z0[i]],[x1[i], y1[i], z1[i]]]

xp0 = p[0,0]
xp1 = p[0,1]
yp0 = p[1,0]
yp1 = p[1,1]
zp0 = p[2,0]
zp1 = p[2,1]

dx = xp1 - xp0
dy = yp1 - yp0
dz = zp1 - zp0
sep = sqrt(dx^2d + dy^2d + dz^2d) ;Length

if sep gt 0 then begin
dx = dx/sep ;Cos th
dy = dy/sep ;Sin th
dz = dz/sep ;Sin th (?) check
endif else begin
dx = 1.
dy = 0.
dz = 0.
sep = 1.
endelse
if arrowsize gt 0 then a = arrowsize $ ;a = length of head
else a = -sep * arrowsize

xxp0 = xp1 + a * (dx*mcost - dy * msint)
yyp0 = yp1 + a * (dx*msint + dy * mcost)
xxp1 = xp1 + a * (dx*mcost - dy * sint)
yyp1 = yp1 + a * (dx*sint + dy * mcost)

if keyword_set(solid) then begin ;Use polyfill?
b = a * mcost*.9d ;End of arrow shaft (Fudge to force join)
plots, [xp0, xp1+b*dx], [yp0, yp1+b*dy],[zp0, zp1+b*dz] /DEVICE, $
COLOR = color, THICK = thick
polyfill, [xxp0, xxp1, xp1, xxp0], [yyp0, yyp1, yp1, yyp0] $
/DEVICE, COLOR = color
endif else begin
plots, [xp0, xp1], [yp0, yp1], [zp0, zp1], COLOR = color, THICK =
thick, /DEVICE
plots, [xxp0,xp1,xxp1],[yyp0,yp1,yyp1], /DEVICE, COLOR = color, $
THICK = hthick
endelse
ENDFOR
end







Norbert Hahn wrote:
> "Nic" <nicole_messages@juno.com> wrote:
>
>> It is making lines (how do I get it to plot arrows?), but I think each
>> time the for loop runs, it is overwriting the previous loop's plots. I
>> want to overplot each new plots to the original surface plot.
>
> You may use arrow in stead of plots. arrow can be called as often as needed
> and will add one or more arrows to an existing plot. Unfortunately the
> coordinates accepted by arrow are 2D. So you need either transform your
> 3D data to 2D by calling convert_coord or modify the call to convert_coord
> within arrow.pro.
>
> HTH
> Norbert
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: large 3D array plot
Next Topic: Re: iplot, /xlog

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

Current Time: Wed Oct 08 13:49:43 PDT 2025

Total time taken to generate the page: 0.00497 seconds