0

I'm trying to draw a piecewise function, and I am modifying the code that I found here: Graph of polynomial, scaling y-axis

This is what my code looks like so far.

\documentclass{article}
\usepackage{tkz-fct}
\begin{document}
\begin{tikzpicture}
\tkzInit[xmin=-5,xmax=5,ymin=-5,ymax=5,ystep=1]   
\tkzGrid
\tkzAxeXY
\tkzFct[color=blue,thick,domain = -5:0]{x**2};
\tkzFct[color=blue,thick,domain = 0:5]{x+1};
\end{tikzpicture}
\end{document}

My question is, now, that I have the function graphed, how can I add the endpoints to the graph. That is, I want an open circle at x=0 for the quadratic and a closed circle at x=1 for the linear function.

Rachel
  • 3
  • 2

1 Answers1

0

The circles can be added once you set up the style (open or closed); then \tkzDefPointByFct will help place the circle at the correct spot.

\documentclass{article}
\usepackage{tkz-fct}
\begin{document}
\begin{tikzpicture}
\tkzInit[xmin=-5,xmax=5,ymin=-5,ymax=5,ystep=1]   
\tkzGrid
\tkzAxeXY
\tkzFct[color=blue,thick,domain = -5:0]{x**2};
\tkzSetUpPoint[shape=circle, size = 5, color=blue, fill=white]
\tkzDefPointByFct(0)
\tkzDrawPoint(tkzPointResult)
\tkzFct[color=blue,thick,domain = 0:5]{x+1};
\tkzSetUpPoint[shape=circle, size = 5, color=blue, fill=blue]
\tkzDefPointByFct(0)
\tkzDrawPoint(tkzPointResult)
\end{tikzpicture}
\end{document}
DJP
  • 12,451
  • This works! Thanks. And does this determine where it is placing the circle by the code placement being directly after the function is drawn plus the \tkzDefPointByFct(0) telling it the input value? Just so I can make other graphs on my own in the future. – Rachel May 29 '20 at 23:27
  • Yes. The macro \tkzDefPointByFct should be placed after the function you will be evaluating. – DJP May 29 '20 at 23:35
  • Thank you. This is helpful. – Rachel May 30 '20 at 21:39