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

Home » Public Forums » archive » PLOT3D format input
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
PLOT3D format input [message #90620] Tue, 17 March 2015 18:04 Go to next message
lucesmm is currently offline  lucesmm
Messages: 26
Registered: October 2014
Junior Member
Hello
I am using PLOT3D
and when the format of my x,y,z vectors is
X FLOAT = Array[200]
Y FLOAT = Array[200]
Z FLOAT = Array[200]

it works

Now, when the format of the vectors is
X FLOAT = Array[1, 108]
Y FLOAT = Array[1, 108]
Z FLOAT = Array[1, 108]

it doesn't work and IDL says that

% Expression must be a scalar or 1 element array in this context: <BYTE Array[2]>

any idea what is happening, my original data is in a (9,108) array. how do I convert them ... this is similar to my code, t is generated from other software

t=FINDGEN(5,200)
x = COS(t) * (1 + t / 10)

help, x
p = PLOT3D(x(0,*), x(1,*), x(2,*),'o')

t=FINDGEN(5,200)
x = t(1,*)
y = t(2,*)
z = t(3,*)

help, x,y,z
p = PLOT3D(x, y, z,'o')
Re: PLOT3D format input [message #90621 is a reply to message #90620] Tue, 17 March 2015 19:49 Go to previous messageGo to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
> t=FINDGEN(5,200)
> x = t(1,*)
> y = t(2,*)
> z = t(3,*)
>
> p = PLOT3D(x, y, z,'o')


I have found that function graphics are particularly picky about whether you pass them a column vector or row vector. Problems arise when you pass data in as a row vector (a 1xN array, as you are doing above). The solution is to reform your data into a column vector (Nx1 array), like so

x = reform(t[1,*])
y = reform(t[2,*])
z = reform(t[3,*])

p = plot3d(x, y, z, 'o')
Re: PLOT3D format input [message #90622 is a reply to message #90621] Tue, 17 March 2015 20:17 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Matthew Argall writes:

>
>> t=FINDGEN(5,200)
>> x = t(1,*)
>> y = t(2,*)
>> z = t(3,*)
>>
>> p = PLOT3D(x, y, z,'o')
>
>
> I have found that function graphics are particularly picky about whether you pass them a column vector or row vector. Problems arise when you pass data in as a row vector (a 1xN array, as you are doing above). The solution is to reform your data into a column vector (Nx1 array), like so
>
> x = reform(t[1,*])
> y = reform(t[2,*])
> z = reform(t[3,*])
>
> p = plot3d(x, y, z, 'o')

Actually, visa versa, but we get the idea. :-)

x = t[1,*] is a column vector.
y = Reform(t[2,*]) is a row vector.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: PLOT3D format input [message #90623 is a reply to message #90622] Wed, 18 March 2015 06:11 Go to previous messageGo to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
Doh! That always gets me. A row vector is a vector full of columns and a column vector is vector full of rows ;-)
Re: PLOT3D format input [message #90626 is a reply to message #90621] Wed, 18 March 2015 12:38 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Hello,

On 03/17/15 22:49, Matthew Argall wrote:
>> t=FINDGEN(5,200)
>> x = t(1,*)
>> y = t(2,*)
>> z = t(3,*)
>>
>> p = PLOT3D(x, y, z,'o')
>
>
> I have found that function graphics are particularly picky about
> whether you pass them a column vector or row vector. Problems arise when
> you pass data in as a row vector (a 1xN array, as you are doing above).
> The solution is to reform your data into a column vector (Nx1 array),
> like so
>
> x = reform(t[1,*])
> y = reform(t[2,*])
> z = reform(t[3,*])
>
> p = plot3d(x, y, z, 'o')

Matthew's suggestion is a good one, but being the memory-layout-worrier
that I am (preferring t[*,0] over t[0,*]), I would simply transpose the
"t" array directly after reading it in from wherever it was created,

The original data...

IDL> t = findgen(5,200)
IDL> help, t
T FLOAT = Array[5, 200]
IDL> print, t[0,*]
0.00000
5.00000
10.0000
15.0000
20.0000
25.0000
30.0000
35.0000
40.0000
45.0000
.....

Transpose it for all subsequent use:

IDL> t = transpose(t)
IDL> help, t
T FLOAT = Array[200, 5]
IDL> print, t[*,0]
0.00000 5.00000 10.0000 15.0000 20.0000
25.0000 30.0000 35.0000 40.0000 45.0000
....

When the trailing dimension is the degenerate one, IDL happily ignores
it....

IDL> x = COS(t) * (1 + t / 10)
IDL> help, x
X FLOAT = Array[200, 5]
IDL> p = PLOT3D(x[*,0], x[*,1], x[*,2],'o')


cheers,

paulv
Re: PLOT3D format input [message #90643 is a reply to message #90626] Thu, 19 March 2015 16:24 Go to previous message
lucesmm is currently offline  lucesmm
Messages: 26
Registered: October 2014
Junior Member
On Wednesday, March 18, 2015 at 12:38:53 PM UTC-7, Paul van Delst wrote:
> Hello,
>
> On 03/17/15 22:49, Matthew Argall wrote:
>>> t=FINDGEN(5,200)
>>> x = t(1,*)
>>> y = t(2,*)
>>> z = t(3,*)
>>>
>>> p = PLOT3D(x, y, z,'o')
>>
>>
>> I have found that function graphics are particularly picky about
>> whether you pass them a column vector or row vector. Problems arise when
>> you pass data in as a row vector (a 1xN array, as you are doing above).
>> The solution is to reform your data into a column vector (Nx1 array),
>> like so
>>
>> x = reform(t[1,*])
>> y = reform(t[2,*])
>> z = reform(t[3,*])
>>
>> p = plot3d(x, y, z, 'o')
>
> Matthew's suggestion is a good one, but being the memory-layout-worrier
> that I am (preferring t[*,0] over t[0,*]), I would simply transpose the
> "t" array directly after reading it in from wherever it was created,
>
> The original data...
>
> IDL> t = findgen(5,200)
> IDL> help, t
> T FLOAT = Array[5, 200]
> IDL> print, t[0,*]
> 0.00000
> 5.00000
> 10.0000
> 15.0000
> 20.0000
> 25.0000
> 30.0000
> 35.0000
> 40.0000
> 45.0000
> .....
>
> Transpose it for all subsequent use:
>
> IDL> t = transpose(t)
> IDL> help, t
> T FLOAT = Array[200, 5]
> IDL> print, t[*,0]
> 0.00000 5.00000 10.0000 15.0000 20.0000
> 25.0000 30.0000 35.0000 40.0000 45.0000
> ....
>
> When the trailing dimension is the degenerate one, IDL happily ignores
> it....
>
> IDL> x = COS(t) * (1 + t / 10)
> IDL> help, x
> X FLOAT = Array[200, 5]
> IDL> p = PLOT3D(x[*,0], x[*,1], x[*,2],'o')
>
>
> cheers,
>
> paulv

Thank you
Now I can plot it.
Sometimes I don't understand how this formatting works...

-LMM
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: ring in fg graphics
Next Topic: IDL Array Indices Command

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

Current Time: Wed Oct 08 15:06:21 PDT 2025

Total time taken to generate the page: 0.00482 seconds