Difference between revisions of "ParametricPlots"
(New page: <h2>Plotting Parametric Functions: PG Code Snippet</h2> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> <em>This code snippet shows the essential PG code to graph...) |
m |
||
Line 47: | Line 47: | ||
<p> |
<p> |
||
Note that this does not set up any default axis labels, so you may need to do that by [[DynamicImages2|adding labels]]. |
Note that this does not set up any default axis labels, so you may need to do that by [[DynamicImages2|adding labels]]. |
||
+ | </p> |
||
</td> |
</td> |
||
</tr> |
</tr> |
Revision as of 15:18, 1 February 2008
Plotting Parametric Functions: PG Code Snippet
This code snippet shows the essential PG code to graph parametrically defined functions. Note that these are insertions, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.
PG problem file | Explanation |
---|---|
loadMacros("PGgraphmacros.pl"); |
As with any dynamically generated graph, we need to include |
$gr = init_graph(-1.5,-1.5,1.5,1.5,axes=>[0,0]); $xfunc = sub { my $t = shift(); return cos($t); }; $yfunc = sub { my $t = shift(); return sin($t); }; $fn = new Fun( $xfunc, $yfunc, $gr ); $fn->domain(0,6.2832); |
To set up the parametric graph, we first define a graph object as for any dynamically generated graph. Then, we specify rules to generate the x and y positions of the parametric plot, and use these in a
Finally, we can set the t domain of the parametrically plotted function with the Note that this does not set up any default axis labels, so you may need to do that by adding labels. |
BEGIN_TEXT \{ image( insertGraph($gr) ) \} END_TEXT |
The graph is then inserted into the problem in the usual manner. |