Difference between revisions of "GraphShading1"
(add historical tag and give links to newer problems.) |
|||
(3 intermediate revisions by one other user not shown) | |||
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/IntegralCalc/GraphShading.html a newer version of this problem]</p> |
||
+ | |||
+ | |||
<h2>Dynamically Generated Graphs With Filled Regions (Shading)</h2> |
<h2>Dynamically Generated Graphs With Filled Regions (Shading)</h2> |
||
Line 5: | Line 10: | ||
This PG code shows how to create a dynamically generated graph with a shaded region. |
This PG code shows how to create a dynamically generated graph with a shaded region. |
||
</p> |
</p> |
||
− | * Download file: [[File:GraphShading1.txt]] (change the file extension from txt to pg when you save it) |
||
+ | * File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/GraphShading1.pg FortLewis/Authoring/Templates/GraphShading1.pg] |
||
− | * File location in NPL: <code>FortLewis/Authoring/Templates/GraphShading1.pg</code> |
||
+ | * PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/GraphShading1_PGML.pg FortLewis/Authoring/Templates/IntegralCalc/GraphShading1_PGML.pg] |
||
<br clear="all" /> |
<br clear="all" /> |
||
Line 202: | Line 207: | ||
Context()->texStrings; |
Context()->texStrings; |
||
BEGIN_SOLUTION |
BEGIN_SOLUTION |
||
− | ${PAR}SOLUTION:${PAR} |
||
Solution explanation goes here. |
Solution explanation goes here. |
||
END_SOLUTION |
END_SOLUTION |
||
Line 225: | Line 229: | ||
[[Category:Top]] |
[[Category:Top]] |
||
− | [[Category: |
+ | [[Category:Sample Problems]] |
+ | [[Category:Subject Area Templates]] |
Latest revision as of 06:12, 18 July 2023
This problem has been replaced with a newer version of this problem
Dynamically Generated Graphs With Filled Regions (Shading)
This PG code shows how to create a dynamically generated graph with a shaded region.
- File location in OPL: FortLewis/Authoring/Templates/GraphShading1.pg
- PGML location in OPL: FortLewis/Authoring/Templates/IntegralCalc/GraphShading1_PGML.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "AnswerFormatHelp.pl", "PGgraphmacros.pl", "unionTables.pl", ); TEXT(beginproblem()); $refreshCachedImages = 1; |
Initialization:
Dynamically generated graphs require |
Context("Numeric"); $a = random(0,3,1); $f = Formula("sqrt(x)+$a"); $answer = Compute("(2/3) * (4^(3/2) - 1) + 3*$a"); # # Graph canvas # $gr = init_graph(-5,-5,5,5,grid=>[10,10],axes=>[0,0],pixels=>[300,300]); # # Graph labels # $gr->lb('reset'); foreach my $j (1..4) { $gr->lb( new Label(-4.7, $j, $j,'black','center','middle')); $gr->lb( new Label(-4.7, -$j,-$j,'black','center','middle')); $gr->lb( new Label( $j,-4.7, $j,'black','center','middle')); $gr->lb( new Label( -$j,-4.7,-$j,'black','center','middle')); } $gr->lb( new Label(4.7,0.2,'x','black','center','middle')); $gr->lb( new Label(0.2,4.7,'y','black','center','middle')); # # Define new graph colors # $gr->new_color("lightblue", 214,230,244); # RGB $gr->new_color("darkblue", 100,100,255); $gr->new_color("lightgreen",156,215,151); $gr->new_color("darkgreen", 0, 86, 34); $gr->new_color("lightred", 245,234,229); # light red-purple $gr->new_color("darkred", 159, 64, 16); # red-brown # # Choose colors # $light = "lightblue"; $dark = "darkblue"; # # Graph the function and the filled region # add_functions($gr, "$f for x in <0,5> using color:$dark and weight:2"); $gr->moveTo(1,$a+1); $gr->lineTo(1,0,$dark,2); $gr->lineTo(4,0,$dark,2); $gr->lineTo(4,$a+2,$dark,2); $gr->fillRegion([1.1,0.1,$light] ); |
Setup:
For more details on the graph object We defined more colors than are actually used so that you have some options to choose from. |
Context()->texStrings; BEGIN_TEXT \{ ColumnTable( "Use the graph to find the area of the shaded region under \( f(x) = $f \). $BR $BR Area = " . ans_rule(20).$SPACE. AnswerFormatHelp("numbers") , image( insertGraph($gr),height=>300,width=>300,tex_size=>800 ). $BR.$BCENTER. $BR. "Graph of \( y = f(x) \)". $ECENTER , indent => 0, separation => 30, valign => "TOP" ) \} END_TEXT Context()->normalStrings; |
Main Text:
We use a two column format provided by
Using a Many existing questions generate image files with larger dimensions than necessary, but scale them down so as to be unreadable in HTML and PDF output, which makes them hard or impossible to use. If you have the time to make a graph, take the extra time to make it an appropriate size in both HTML and PDF output. |
$showPartialCorrectAnswers = 1; ANS( $answer->cmp() ); |
Answer Evaluation: |
Context()->texStrings; BEGIN_SOLUTION Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |