mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-26 06:48:04 +02:00
26 lines
No EOL
1 KiB
TeX
26 lines
No EOL
1 KiB
TeX
\begin{tikzpicture}
|
|
\begin{axis}[
|
|
legend pos=south west,
|
|
axis x line=middle,
|
|
axis y line=middle,
|
|
grid = major,
|
|
grid style={dashed, gray!30},
|
|
xmin=-1, % start the diagram at this x-coordinate
|
|
xmax= 6, % end the diagram at this x-coordinate
|
|
ymin=-0.25, % start the diagram at this y-coordinate
|
|
ymax= 2.25, % end the diagram at this y-coordinate
|
|
axis background/.style={fill=white},
|
|
xlabel=$x$,
|
|
ylabel=$y$,
|
|
tick align=outside,
|
|
minor tick num=-3,
|
|
enlargelimits=true,
|
|
tension=0.08]
|
|
\addplot[domain=0:1, red, thick,samples=20] {0.5*x*x};
|
|
\addplot[domain=1:2, green, thick,samples=20] {x-0.5};
|
|
\addplot[domain=2:3, blue, thick,samples=500] {-0.5*(x-2)*(x-2)+x-0.5};
|
|
\addplot[domain=3:5, purple, thick,samples=20] {5-x};
|
|
\addplot[domain=5:7, orange, thick,samples=3] {0};
|
|
\addplot[domain=-3:0, orange, thick,samples=3] {0};
|
|
\end{axis}
|
|
\end{tikzpicture} |