6

How to indicate "including" and "excluding" dots on the graph?

\documentclass[paper=a4, fontsize=11pt]{scrartcl} 
 \usepackage{pgfplots, pgfplotstable}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}
    \begin{axis}
    \addplot[very thick, smooth,samples=200,domain=-2:0]{0};
    \addplot[very thick, smooth,samples=200,domain=0:0.5]{2*x};
    \addplot[very thick, smooth,samples=200,domain=0.5:1]{6-6*x};
    \addplot[very thick, smooth,samples=200,domain=1:2]{0};
    \end{axis}
    \end{tikzpicture}


\end{document}

Thanks in advance!

2
  • 1
    Can you explain a little more what you want?
    – osjerick
    Sep 12, 2014 at 17:03
  • 1
    @OSjerick I think the OP means this. This answer by Jake may be a first step towards a solution.
    – jub0bs
    Sep 12, 2014 at 17:59

1 Answer 1

6

Do you mean that you want to use different markers on either side of the discontinuity?

Here is a possible (though kind of tedious) approach; I don't know of a more automated way of doing that with pgfplots, but maybe there is one... Time will tell.

enter image description here

\documentclass{article}

\usepackage{pgfplots}

\tikzset{
  jumpdot/.style={mark=*,solid},
  excl/.append style={jumpdot,fill=white},
  incl/.append style={jumpdot,fill=black},
}

\begin{document}
  \begin{tikzpicture}
    \begin{axis}
        \addplot[very thick, smooth,samples=200,domain=-2:0]{0};
        \addplot[very thick, smooth,samples=200,domain=0:0.5]{2*x};
        \addplot[incl] coordinates {(.5,1)};
        \addplot[very thick, smooth,samples=200,domain=0.5:1]{6-6*x};
        \addplot[excl] coordinates {(.5,3)};
        \addplot[very thick, smooth,samples=200,domain=1:2]{0};
    \end{axis}
  \end{tikzpicture}
\end{document}
1
  • 1
    This is exactly what I was looking for. And your code worked perfectly (which is sometimes not the case with provided answers.)
    – Olga
    Sep 12, 2014 at 21:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .