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

Home » Public Forums » archive » Plotting a 3D Array In IDL
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
Plotting a 3D Array In IDL [message #25778] Tue, 17 July 2001 16:56 Go to next message
K. Banerjee is currently offline  K. Banerjee
Messages: 4
Registered: July 2001
Junior Member
Say I have a 3D array whose elements are only 1 or 0. I'd like to plot
this array, say a white dot for the 1's and a red dot for the 0's. Is there
a way I can do this in IDL?

(I'm fairly new to IDL and thre's probably a straight forward
way to do this!)

Thanks.

K. Banerjee
Re: Plotting a 3D Array In IDL [message #25849 is a reply to message #25778] Thu, 19 July 2001 07:16 Go to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
eddie haskell wrote:
>
>> Say I have a 3D array whose elements are only 1 or 0. I'd like to plot
>> this array, say a white dot for the 1's and a red dot for the 0's. Is there
>> a way I can do this in IDL?
>
> Below is a program fragment that does what I think you want done. There might
> be a slick one line way of doing it or maybe something visually stunning using
> object graphics but nothing currently leaps to mind.
>
> Cheers,
> eddie
>
> ;--------------------------
> n = 4
> a = randomu(seed,n,n,n) gt 0.5
> surface, dist(n), /nodata, zr=[0,n-1], /save
> tvlct,[0,255],[255,0],[0,0],1
>
> for j = 0,1 do begin
> wh = where(a eq j)
> x = wh mod n
> y = wh / n mod n
> z = wh / n^2
> for i = 0, n_elements(wh)-1 do $
> plots,x[i],y[i],z[i],/t3d,psym=2,color=j+1
> endfor
> ;-----------------------

Cool - I couldn't figure out how to do it. I modified the above a little to use plot3d

n = 4
a = randomu(seed,n,n,n) gt 0.5
tvlct,[0,255],[255,0],[0,0],1

for j = 0,1 do begin
wh = where(a eq j)
x = wh mod n
y = wh / n mod n
z = wh / n^2
plot3d, x,y,z,psym=2,color=j+1,oplot=j
endfor

but I find the resultant plot hard to interpret. I think this is a case where object
graphics is required to give some depth to the plot by varying the size of the plotting
symbols with perceived depth... or something like that.

paulv

--
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
Alexander Pope.
Re: Plotting a 3D Array In IDL [message #25855 is a reply to message #25778] Wed, 18 July 2001 20:05 Go to previous message
david[2] is currently offline  david[2]
Messages: 100
Registered: June 2001
Senior Member
K. Banerjee writes:

> Between 3,000 and 4,000.

Yeah, bad news. :-(

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Plotting a 3D Array In IDL [message #25863 is a reply to message #25778] Wed, 18 July 2001 09:20 Go to previous message
eddie haskell is currently offline  eddie haskell
Messages: 29
Registered: September 1998
Junior Member
> Say I have a 3D array whose elements are only 1 or 0. I'd like to plot
> this array, say a white dot for the 1's and a red dot for the 0's. Is there
> a way I can do this in IDL?

Below is a program fragment that does what I think you want done. There might
be a slick one line way of doing it or maybe something visually stunning using
object graphics but nothing currently leaps to mind.

Cheers,
eddie

;--------------------------
n = 4
a = randomu(seed,n,n,n) gt 0.5
surface, dist(n), /nodata, zr=[0,n-1], /save
tvlct,[0,255],[255,0],[0,0],1

for j = 0,1 do begin
wh = where(a eq j)
x = wh mod n
y = wh / n mod n
z = wh / n^2
for i = 0, n_elements(wh)-1 do $
plots,x[i],y[i],z[i],/t3d,psym=2,color=j+1
endfor
;-----------------------

------------------------------------------
A G Edward Haskell
Center for Coastal Physical Oceanography
Old Dominion University, Norfolk VA 23529
e-mail haskell*ccpo.odu.edu
------------------------------------------
Re: Plotting a 3D Array In IDL [message #25864 is a reply to message #25778] Wed, 18 July 2001 09:07 Go to previous message
Pavel A. Romashkin is currently offline  Pavel A. Romashkin
Messages: 531
Registered: November 2000
Senior Member
Could you give an idea what kind of a plot you want to make?
Do you mean 3D to be Array[10,10,10] or is it an XYZ-type data set - Array[10,10]?

Cheers,
Pavel

"K. Banerjee" wrote:
>
> Say I have a 3D array whose elements are only 1 or 0. I'd like to plot
> this array, say a white dot for the 1's and a red dot for the 0's. Is there
> a way I can do this in IDL?
>
> (I'm fairly new to IDL and thre's probably a straight forward
> way to do this!)
>
> Thanks.
>
> K. Banerjee
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: emacs idlwave shell key bindings
Next Topic: How to get PV-Wave to exit automatically when no license

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

Current Time: Wed Oct 08 15:17:10 PDT 2025

Total time taken to generate the page: 0.00542 seconds