Easy tutorial on how to make 3-dimensional graphics

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Easy tutorial on how to make 3-dimensional graphics

Tetsuji Rai
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi, all

I want to make graphics like the one on

http://www.octave.org/

provided z=f(x,y) to display particle densities on various conditions on
quantum mechanics.

Where can I find easy script examples?  I know how to plot in
2-dimensional graphs.

Thanks in advance!

- -Tetsuji
- --
Tetsuji 'Maverick' Rai
main page http://maverick6664.bravehost.com/
PGP pubkey http://mav.atspace.com/maverick31337_at_gmail_dot_com.txt
PGP Key ID: 0x971E57CA
Key fingerprint: F790 28AF E95B 48C9 19AB  71FD 50B5 3572 971E 57CA
Aviation Jokes: http://www.geocities.com/tetsuji_rai/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFDw9z9ULU1cpceV8oRAsuQAJwKNe/2ik8/z749bWXePsIRpNO/EACdELsq
eR6vzg4ldGGl9M2YH0lVTLI=
=D8xW
-----END PGP SIGNATURE-----



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: Easy tutorial on how to make 3-dimensional graphics

Quentin Spencer
Tetsuji "Maverick" Rai wrote:

>I want to make graphics like the one on
>
>http://www.octave.org/
>
>provided z=f(x,y) to display particle densities on various conditions on
>quantum mechanics.
>
>Where can I find easy script examples?  I know how to plot in
>2-dimensional graphs.
>
>Thanks in advance!
>  
>

The plot you are refering to was created using the "sombrero" function
that is part of octave. You can view the code that was used to create it
by entering "type sombrero" at the octave prompt.

-Quentin



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: Easy tutorial on how to make 3-dimensional graphics

Tetsuji Rai
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quentin Spencer wrote:

> Tetsuji "Maverick" Rai wrote:
>
>> I want to make graphics like the one on
>>
>> http://www.octave.org/
>>
>> provided z=f(x,y) to display particle densities on various conditions on
>> quantum mechanics.
>>
>> Where can I find easy script examples?  I know how to plot in
>> 2-dimensional graphs.
>>
>> Thanks in advance!
>>  
>>
>
> The plot you are refering to was created using the "sombrero" function
> that is part of octave. You can view the code that was used to create it
> by entering "type sombrero" at the octave prompt.
>
> -Quentin
>
>

Thanks!

- -Tetsuji

- --
Tetsuji 'Maverick' Rai
main page http://maverick6664.bravehost.com/
PGP pubkey http://mav.atspace.com/maverick31337_at_gmail_dot_com.txt
PGP Key ID: 0x971E57CA
Key fingerprint: F790 28AF E95B 48C9 19AB  71FD 50B5 3572 971E 57CA
Aviation Jokes: http://www.geocities.com/tetsuji_rai/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFDw+EaULU1cpceV8oRApYSAJ9J3Ql4tCcCfknxMLm6cwazgS60zQCfS2oA
fcr/eHe7FABVuFc5uT3PGEU=
=cpLO
-----END PGP SIGNATURE-----



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: Easy tutorial on how to make 3-dimensional graphics

Stéfan van der Walt
In reply to this post by Tetsuji Rai
The code to generate the sombrero is shown on the Wiki at

http://wiki.octave.org/wiki.pl?SimpleExamples

Unfortunately, it is outdated.  Much has been happening around
the plotting engine.. (you can probably make it work by using
__gnuplot_set__ instead of gset, though).

Regards
Stéfan

On Wed, Jan 11, 2006 at 01:12:46AM +0900, Tetsuji Maverick Rai wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi, all
>
> I want to make graphics like the one on
>
> http://www.octave.org/
>
> provided z=f(x,y) to display particle densities on various conditions on
> quantum mechanics.



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: Easy tutorial on how to make 3-dimensional graphics

Tetsuji Rai
In reply to this post by Quentin Spencer
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quentin Spencer wrote:

> Tetsuji "Maverick" Rai wrote:
>
>> I want to make graphics like the one on
>>
>> http://www.octave.org/
>>
>> provided z=f(x,y) to display particle densities on various conditions on
>> quantum mechanics.
>>
>> Where can I find easy script examples?  I know how to plot in
>> 2-dimensional graphs.
>>
>> Thanks in advance!
>>  
>>
>
> The plot you are refering to was created using the "sombrero" function
> that is part of octave. You can view the code that was used to create it
> by entering "type sombrero" at the octave prompt.
>
> -Quentin
>
>
Thanks!  I understood how to plot in 3-dimensional space.  Then how can
I "rotate" or "pitch up/down" this 3-dimension graphics display?  I
cannot find it in the online document 17.3 "Three-Dimensional Plotting."

- --
Tetsuji 'Maverick' Rai
main page http://maverick6664.bravehost.com/
PGP pubkey http://mav.atspace.com/maverick31337_at_gmail_dot_com.txt
PGP Key ID: 0x971E57CA
Key fingerprint: F790 28AF E95B 48C9 19AB  71FD 50B5 3572 971E 57CA
Aviation Jokes: http://www.geocities.com/tetsuji_rai/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFDw/79ULU1cpceV8oRArwFAKCGKDw0YXJPIiaHRGD7qdl4/ld2hwCfaQNX
WctbBqcHNMQXfto8q39AEms=
=4DWO
-----END PGP SIGNATURE-----



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: Easy tutorial on how to make 3-dimensional graphics

Quentin Spencer
Tetsuji "Maverick" Rai wrote:

>Thanks!  I understood how to plot in 3-dimensional space.  Then how can
>I "rotate" or "pitch up/down" this 3-dimension graphics display?  I
>cannot find it in the online document 17.3 "Three-Dimensional Plotting."
>  
>

See "help view" for a way to do it from the command line. It can also be
done interactively with the mouse in gnuplot 4.0 (I don't think you can
in the older versions), but you need to put "set mouse" in your .gnuplot
file in order to enable it (an uglier way is to enter
__gnuplot_raw__("set mouse\n") in octave before you create the 3-d plot).

-Quentin




-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: Easy tutorial on how to make 3-dimensional graphics

Tetsuji Rai
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quentin Spencer wrote:

> Tetsuji "Maverick" Rai wrote:
>
>> Thanks!  I understood how to plot in 3-dimensional space.  Then how can
>> I "rotate" or "pitch up/down" this 3-dimension graphics display?  I
>> cannot find it in the online document 17.3 "Three-Dimensional Plotting."
>>  
>>
>
> See "help view" for a way to do it from the command line. It can also be
> done interactively with the mouse in gnuplot 4.0 (I don't think you can
> in the older versions), but you need to put "set mouse" in your .gnuplot
> file in order to enable it (an uglier way is to enter
> __gnuplot_raw__("set mouse\n") in octave before you create the 3-d plot).
>
> -Quentin
>
>
>

Thank you!  It works very well and this is what I wanted.

- --
Tetsuji 'Maverick' Rai
main page http://maverick6664.bravehost.com/
PGP pubkey http://mav.atspace.com/maverick31337_at_gmail_dot_com.txt
PGP Key ID: 0x971E57CA
Key fingerprint: F790 28AF E95B 48C9 19AB  71FD 50B5 3572 971E 57CA
Aviation Jokes: http://www.geocities.com/tetsuji_rai/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFDxUsNULU1cpceV8oRApc7AKCJgef/ZBoJExspkzwf0JhueaKjwACgkeRc
jLEjvVwLBGdBOqwiZTExr/Q=
=/9Tp
-----END PGP SIGNATURE-----



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: Easy tutorial on how to make 3-dimensional graphics

Tetsuji Rai
In reply to this post by Quentin Spencer
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quentin Spencer wrote:

> Tetsuji "Maverick" Rai wrote:
>
>> Thanks!  I understood how to plot in 3-dimensional space.  Then how can
>> I "rotate" or "pitch up/down" this 3-dimension graphics display?  I
>> cannot find it in the online document 17.3 "Three-Dimensional Plotting."
>>  
>>
>
> See "help view" for a way to do it from the command line. It can also be
> done interactively with the mouse in gnuplot 4.0 (I don't think you can
> in the older versions), but you need to put "set mouse" in your .gnuplot
> file in order to enable it (an uglier way is to enter
> __gnuplot_raw__("set mouse\n") in octave before you create the 3-d plot).
>
> -Quentin
>
>
>

Thank you for your help...

I'm a newbie on octave.

Now I've begun writing a small function to make a 3-d plot, but I'm
stuck at linspace(,,).  Following function fails like

octave:2> h100(1)
error: linspace: npoints is 1, but x1 != x2
error: evaluating assignment expression near line 6, column 9
error: evaluating assignment expression near line 6, column 5
error: called from `h100' in file
`/home/tetsuji/physics/hydrogen-atom/h100.m'

- ----h100.m----
function h100(dn)

  a0 = 1;
  n = 1;

  x = z = linspace (-10, 10, dn);
  [xx, zz] = meshgrid (x,z);
  [theta,r] = cart2pol (zz,xx);

  r1 = 1 ./(n*a0);
  y = r1 .^1.5 * exp(-r1*r);
  y = y*y ./ pi;

  mesh(x,z,y);
endfunction
- ---------------

Apparently x and z has a problem (I think I just borrowed this line from
sombrero(n)).  I must be doing something wrong, but don't know what's
wrong..  Looking at sombrero(n), I see a single quote after
linspace(-8,8,n) and a period before slash '/' or hat '^'..... What are
they??  As for math, C++ is much easier to me... very unusual :(

In above function, x and z axes are on the horizontal plane, and y axis
stands vertically.

So are there any good online tutorial for octave (not document on
www.octave.org)?

- -Tetsuji
- --
Tetsuji 'Maverick' Rai
main page http://maverick6664.bravehost.com/
PGP pubkey http://mav.atspace.com/maverick31337_at_gmail_dot_com.txt
PGP Key ID: 0x971E57CA
Key fingerprint: F790 28AF E95B 48C9 19AB  71FD 50B5 3572 971E 57CA
Aviation Jokes: http://www.geocities.com/tetsuji_rai/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFDxnD3ULU1cpceV8oRAoyFAKCRmWi/5QDgLf/jEX4H8vjbl3bStQCeOOha
qIrB9KTUXKM98PWRl4btshM=
=Cvcy
-----END PGP SIGNATURE-----



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: Easy tutorial on how to make 3-dimensional graphics

Quentin Spencer
Tetsuji "Maverick" Rai wrote:

>Thank you for your help...
>
>I'm a newbie on octave.
>
>Now I've begun writing a small function to make a 3-d plot, but I'm
>stuck at linspace(,,).  Following function fails like
>
>octave:2> h100(1)
>error: linspace: npoints is 1, but x1 != x2
>error: evaluating assignment expression near line 6, column 9
>error: evaluating assignment expression near line 6, column 5
>error: called from `h100' in file
>`/home/tetsuji/physics/hydrogen-atom/h100.m'
>
>- ----h100.m----
>function h100(dn)
>
>  a0 = 1;
>  n = 1;
>
>  x = z = linspace (-10, 10, dn);
>  [xx, zz] = meshgrid (x,z);
>  [theta,r] = cart2pol (zz,xx);
>
>  r1 = 1 ./(n*a0);
>  y = r1 .^1.5 * exp(-r1*r);
>  y = y*y ./ pi;
>
>  mesh(x,z,y);
>endfunction
>- ---------------
>
>  
>

The last argument to the linspace function must be >1. Type help
linspace to learn why.

>Apparently x and z has a problem (I think I just borrowed this line from
>sombrero(n)).  I must be doing something wrong, but don't know what's
>wrong..  Looking at sombrero(n), I see a single quote after
>linspace(-8,8,n) and a period before slash '/' or hat '^'..... What are
>they??  As for math, C++ is much easier to me... very unusual :(
>  
>

In octave, a*b represents a matrix multiplication of matrices a and b
(which requires that they have the correct dimensions). That is
different than element-wise multiplication of a and b, so that is
represented with the symbol ".*". Since the operators / and ^ also have
special meanings for matrix operations, if you want to divide all of the
elements in one vector or matrix by all of the elements in another of
the same dimensions, you use "./"; the same is true for exponents and
the ".^" operator. The single quote represents the transpose of a matrix.

>In above function, x and z axes are on the horizontal plane, and y axis
>stands vertically.
>
>So are there any good online tutorial for octave (not document on
>www.octave.org)?
>  
>

Maybe, but I don't know where. Maybe someone else can respond with
suggestions.

-Quentin



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: Easy tutorial on how to make 3-dimensional graphics

Tetsuji Rai
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quentin Spencer wrote:

> Tetsuji "Maverick" Rai wrote:
>
>> Thank you for your help...
>>
>> I'm a newbie on octave.
>>
>> Now I've begun writing a small function to make a 3-d plot, but I'm
>> stuck at linspace(,,).  Following function fails like
>>  snip....
>
> The last argument to the linspace function must be >1. Type help
> linspace to learn why.
>

Thanks.  I've got it to work w/o any modifications.  It worked like a
charm (yes, it's like a charm to the "current" me :) ).  I forgot I used
sombrero(32) or larger to test sombrero(n)....

>> Apparently x and z has a problem (I think I just borrowed this line from
>> sombrero(n)).  I must be doing something wrong, but don't know what's
>> wrong..  Looking at sombrero(n), I see a single quote after
>> linspace(-8,8,n) and a period before slash '/' or hat '^'..... What are
>> they??  As for math, C++ is much easier to me... very unusual :(
>>  
>>
>
> In octave, a*b represents a matrix multiplication of matrices a and b
> (which requires that they have the correct dimensions). That is
> different than element-wise multiplication of a and b, so that is
> represented with the symbol ".*". Since the operators / and ^ also have
> special meanings for matrix operations, if you want to divide all of the
> elements in one vector or matrix by all of the elements in another of
> the same dimensions, you use "./"; the same is true for exponents and
> the ".^" operator. The single quote represents the transpose of a matrix.
>

Thank you for your help!  It's very clear!   Then I need to read "375
page manual" online and ask here when necessary...

- -Tetsuji
- --
Tetsuji 'Maverick' Rai
main page http://maverick6664.bravehost.com/
PGP pubkey http://mav.atspace.com/maverick31337_at_gmail_dot_com.txt
PGP Key ID: 0x971E57CA
Key fingerprint: F790 28AF E95B 48C9 19AB  71FD 50B5 3572 971E 57CA
Aviation Jokes: http://www.geocities.com/tetsuji_rai/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFDxnvnULU1cpceV8oRAiGpAJwLH0Fg0NUwf9ZE7xB6OYyvNtiQpgCeIPsn
0dzJ0AXB5++9QttI+U7LvSk=
=cM8P
-----END PGP SIGNATURE-----



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------