# Part 8: Function plots¶

Any question can be augmented by a canvas with a plot of several functions.

• define a function by \function{f}{ expression} using the \function command explained before
• using \plotF{1}{f} this f is registered for drawing (as 1st drawable function, the next one e.g. \plotF{2}{g})
• using \plotFrom{1}{ number} the left bound of the (first) function's domain is defined
• using \plotTo{1}{ number} the right bound of the function's domain is defined
• use \plotColor{1}{ color} to define the plot color (black, red, green, blue, yellow, magenta, pink, gray, orange, white are possible values, case is ignored, if you write vanilla or something it's interpreted as white )
• use \plotLeft{ number} to define the leftmost canvas ordinate, and \plotRight{ number} for the rightmost one
• use \plotSize{ integer} to define the size of the canvas, default is 300
• use \plotRatio{keep} to keep the ratio of the two coordinate axises 1:1, default is 'auto' that scales the y-axis based on the functions that are plotted

Here is a complete example:

\usepackage{mumie.genericproblem}

\lang{en}{
\title{testing plots}
}
\lang{de}{
\title{Plot-Test}
}

\begin{problem}

\begin{question}
\begin{variables}
\function{a1}{1}                    %%first part of the graph, a horizontal line
\function{a2}{2-sqrt(1-(x-1)^2)}    %%followed by a quarter of a circle (observe it will be rescaled for the graphics, so it visually becomes an elliptic segment)
\function{a3}{2+sqrt(1-(x-1)^2)}    %%and a second quarter, together forming a reversed 'C'
\function{a4}{0}                    %%this is the domain interval
\end{variables}

\text{1. Is the blue graph to the right the graph of a function defined on the red domain?}
\type{yesno}
\field{rational}
\explanation{This explains everything in case of wrong answer...} %%only for correction

\plotF{1}{a1}           %%the function a1 is defined below in 'variables' in the usual way
\plotFrom{1}{0.0}       %%and is plotted starting from 0.0
\plotTo{1}{1.0}         %%and ending in 1.0 , it's a quarter of a circle
\plotColor{1}{blue}     %%colored blue

\plotF{2}{a2}           %%same for a2
\plotFrom{2}{1.0}
\plotTo{2}{2.0}
\plotColor{2}{blue}

\plotF{3}{a3}
\plotFrom{3}{1.0}
\plotTo{3}{2.0}
\plotColor{3}{blue}

\plotF{4}{a4}           %%domain
\plotFrom{4}{0.0}
\plotTo{4}{2.0}
\plotColor{4}{red}      %%domain color

\plotLeft{0}            %%defines the canvas bound left
\plotRight{3}           %%and right
\plotSize{200}          %%function plot canvas has size 200x200 instead of default 300x300

\begin{choice}
\text{Yes or no?}
\solution{false}
\end{choice}
\end{question}

\end{problem}


Add picture from clipboard (Maximum size: 500 MB)