Difference between revisions of "TikZImages"
Jump to navigation
Jump to search
Line 120: | Line 120: | ||
<ul> |
<ul> |
||
<li>POD documentation: [https://webwork.maa.org/pod/pg/macros/PGtikz.html PGtikz.pl]</li> |
<li>POD documentation: [https://webwork.maa.org/pod/pg/macros/PGtikz.html PGtikz.pl]</li> |
||
− | <li>PG macro: [ |
+ | <li>PG macro: [https://github.com/openwebwork/pg/blob/master/macros/PGtikz.pl PGtikz.pl]</li> |
</ul> |
</ul> |
Revision as of 22:42, 14 April 2021
Graphic Images, TikZImages
This example shows how to create an image/plot using Tikz.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PGML.pl", "PGtikz.pl" ); TEXT(beginproblem()); |
Initialization: It is important to include the PGtikz.pl macro. |
$graph_image = createTikZImage(); $graph_image->tikzLibraries("arrows.meta"); $graph_image->BEGIN_TIKZ \draw[<->,thick] (-11,0) -- (11,0) node[above left,outer sep=2pt]{\(x\)}; \draw[<->,thick] (0,-11) -- (0,11) node[below right,outer sep=2pt]{\(y\)}; \foreach \x in {-10,-8,...,-2,2,4,...,10} \draw[thin] (\x,5pt) -- (\x,-5pt) node[below]{\(\x\)}; \foreach \y in {-10,-8,...,-2,2,4,...,10} \draw[thin] (5pt,\y) -- (-5pt,\y) node[left]{\(\y\)}; \draw[<->,red] plot[domain={-3.2+$a}:{3.2+$a}] (\x,{pow(\x-$a,2)+$b}); END_TIKZ |
Setup:
Notes: on using this and related Contexts. |
BEGIN_PGML [@ image(insertGraph($graph_image), width => 300, tex_size => 1000) @]* END_PGML |
Main Text: This is how to insert the tikz image. Note the width and tex_size parameters can change the size of the image on the web and as hardcopy. |
ENDDOCUMENT(); |
This doesn't have a question, so we aren't checking an answer. |