Difference between revisions of "ParametricPlots"
(added historical tag and gave updated problem link) |
|||
Line 1: | Line 1: | ||
+ | {{historical}} |
||
+ | |||
+ | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Parametric/ParametricPlot.html a newer version of this problem]</p> |
||
<h2>Plotting Parametric Functions: PG Code Snippet</h2> |
<h2>Plotting Parametric Functions: PG Code Snippet</h2> |
||
Latest revision as of 09:45, 29 June 2023
This problem has been replaced with a newer version of this problem
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. |