Forum archive 2000-2006

Lars Jensen - Format number of sample points on graph?

Lars Jensen - Format number of sample points on graph?

by Arnold Pizer -
Number of replies: 0
inactiveTopicFormat number of sample points on graph? topic started 8/1/2004; 5:25:14 PM
last post 8/6/2004; 5:37:13 PM
userLars Jensen - Format number of sample points on graph?  blueArrow
8/1/2004; 5:25:14 PM (reads: 1138, responses: 4)
When producing a graph for a problem, how do I increase the number of sample points on the graph, so the plot looks less jagged?

Thanks, Lars.

<| Post or View Comments |>


userMichael Gage - Re: Format number of sample points on graph?  blueArrow
8/2/2004; 1:05:18 PM (reads: 1335, responses: 0)
Hi Lars,

Look at http://webhost.math.rochester.edu/webworkdocs/docs/pglanguage/pod/fun#properites

which describes the commands in Fun.pm

Once you have created a Function object $fn, you can change the number of steps used in graphing the function using

$fn->steps(50);

you can determine the current or default value with

$current_steps = $fn->steps();

You can also reset the domain of the function.

-- Mike

<| Post or View Comments |>


userLars Jensen - Re: Format number of sample points on graph?  blueArrow
8/3/2004; 6:42:37 PM (reads: 1361, responses: 0)
Hi Mike,

Thanks for your response. Your method is not immediately clear to me - I was using the method described in Shemanske's "Newbie Guide" to include the graph...

Are there any good sample problem in one of the libraries that uses above method?

Thanks, Lars.

<| Post or View Comments |>


userMichael Gage - Re: Format number of sample points on graph?  blueArrow
8/4/2004; 3:05:57 PM (reads: 1322, responses: 0)
Perhaps this will help. (It's from PGgraphmacros.pl description. Slightly cleaned up from that description)

 



$f1 = FEQ( qq! x^2 - 3*x + 45 for x in [0, 45) using color:red and weight:2!);




Usage: ($fn1, $fn2, $fn3) = plot_functions($graph, $f1, $f2, $f3);
Synonym: add_functions($graph,$f1,$f2,$f3);

(This isn't has clear as it should be in the original description since the outputs there were also labeled $f1, $f2 and $f3. The $f1 output (now called $fn1) is a function object, while the $f1 input is just a string.

plot_functions was designed as a front end macro which simplies constructing function objects. The output of plot_functions is a Fun with the methods described in Fun.pm.

To change the number of points in plotting the function you need the following statement, after the plot_functions statement, but before the "insertGraph" statement.

 

$fn1->steps(100);

This will set the number of steps used in plotting the function to 100. You might also try setting it first to 4 steps so that you can clearly see the effect of changing the number of steps. Note that despite its name, plot_functions doesn't actually draw the graph when it is executed, it translates the string into a function object capable of drawing the graph, and returns a reference to the function object. (It also inserts this function object into the graph.) The graph is not actually crteated/drawn until the insertGraph command is executed, so changes made in the function objects before that command will affect the graph.

Hope this helps.

-- Mike

<| Post or View Comments |>


userLars Jensen - Re: Format number of sample points on graph?  blueArrow
8/6/2004; 5:37:13 PM (reads: 1340, responses: 0)
Hi Mike,

Thanks a lot. This really helped.

Lars.

<| Post or View Comments |>