- #1
adamwest
- 10
- 1
I am brand new to Gnuplot and am having a problem trying to figure out how to graph in Polar Coordinates for a school assignment. What bothers me is we didn't go over other coordinate systems like Polar or Parametric at all for Gnuplot, and the internet tutorials I find seem to assume some basic knowledge and just tell me to do "set polar".
1. The problem I am trying to solve:
The electron density around a particular molecule centered at the origin is described by
n(r,theta) = [cos(r)]^2 * {1+[cos(theta)]^2} * exp(-r^2/25)
where r and theta are usual polar coordinates [e.g., (x,y) = (r*cos(theta),r*sin(theta))].
Write a gnuplot script elec.gpl that generates a surface plot of this function on a domain of x=-5..5 and y=-5..5. Set your script so that
gnuplot> elec.gpl
generates the plot as a postscript file called "elec.ps"
None, just miscellaneous commands listed below
set terminal png enhanced
set output 'elec.ps'
set polar
set angle degrees
set title 'Electron Density Around Molecule'
set xrange[-5:5]
set yrange[-5:5]
set grid
set grid polar
plot (cos(x))^2 *(1+(cos(y))^2)*exp(-x^2/25)
quit
I have tried changing x to r, y to t, y to theta, etc. I simply can't figure out how Gnuplot wants me to define polar coordinate inputs. Is there a way to redefine x as r*cos(theta) and y as r*sin(theta) and then let me set inputs and ranges for r and theta? I bet the answer is something obvious because Gnuplot is REALLY easy to use for rectangular coordinates.
Thank you for your help! :)
1. The problem I am trying to solve:
The electron density around a particular molecule centered at the origin is described by
n(r,theta) = [cos(r)]^2 * {1+[cos(theta)]^2} * exp(-r^2/25)
where r and theta are usual polar coordinates [e.g., (x,y) = (r*cos(theta),r*sin(theta))].
Write a gnuplot script elec.gpl that generates a surface plot of this function on a domain of x=-5..5 and y=-5..5. Set your script so that
gnuplot> elec.gpl
generates the plot as a postscript file called "elec.ps"
Homework Equations
None, just miscellaneous commands listed below
The Attempt at a Solution
set terminal png enhanced
set output 'elec.ps'
set polar
set angle degrees
set title 'Electron Density Around Molecule'
set xrange[-5:5]
set yrange[-5:5]
set grid
set grid polar
plot (cos(x))^2 *(1+(cos(y))^2)*exp(-x^2/25)
quit
I have tried changing x to r, y to t, y to theta, etc. I simply can't figure out how Gnuplot wants me to define polar coordinate inputs. Is there a way to redefine x as r*cos(theta) and y as r*sin(theta) and then let me set inputs and ranges for r and theta? I bet the answer is something obvious because Gnuplot is REALLY easy to use for rectangular coordinates.
Thank you for your help! :)