TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I plot a non-continuous function with TikZ (using continuous lines for continous stretches of the function and dashed lines for discontinuities)? Does anybody know an efficient method?

share|improve this question

I am not sure if this is what you want, but I would suggest you to use the pgfplots package (internally uses TikZ); a little example (the solid and hollow dot styles are borrowed from a comment by cmhughes):


\pgfplotsset{soldot/.style={color=blue,only marks,mark=*}} \pgfplotsset{holdot/.style={color=blue,fill=white,only marks,mark=*}}


\addplot[domain=0:4,blue] {x*x};
\addplot[domain=4:6,blue] {x};
\addplot[domain=6:10,blue] {-5};
\draw[dotted] (axis cs:4,16) -- (axis cs:4,4);
\draw[dotted] (axis cs:6,6) -- (axis cs:6,-5);
\addplot[holdot] coordinates{(0,0)(4,4)(6,-5)};
\addplot[soldot] coordinates{(4,16)(6,6)(10,-5)};


enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.