1

How do I represent periodic functions in LaTeX that also have discontinuities? I tried the pgfplots package. But it seems like the package does not support discontinuous functions.

enter image description here

Mico
  • 506,678
  • 1
    You can definitely produce your figure with pgfplots, see e.g. https://tex.stackexchange.com/a/544697/194703. –  May 18 '20 at 15:32
  • 1
    The graph you show is continuous as it can be traced without removing the pencil from the paper. If you mean for the vertical line to be gone (so it's a true function) you just need to adjust your graph using an open circle or closed circle like is shown at the link. – DJP May 18 '20 at 15:53
  • 1
    Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. – Stefan Pinnow May 18 '20 at 16:49

1 Answers1

2

Here are some solutions if you are using tabular data for the plot

\documentclass[tikz,margin=3.14mm]{standalone}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
    \begin{axis}[
            axis equal,
            axis x line=bottom,axis y line=left,
            enlargelimits=true,
            legend style={at={(0,1.05)},anchor=south west},
        ]
        % If you want the vertical line at x=0
        \addplot+ table{
                -3 1
                -2 1
                -1 0
                0 0
                0 1
                1 1
                2 0
                3 0
            };
        % If you want the vertical line at x=0
        \addplot+ table{
                -3 1
                -2 1
                -1 0
                0 0

                0 1
                1 1
                2 0
                3 0
            };
        % If you want the vertical line at x=0
        \addplot+[dashed,unbounded coords=jump] table{
                -3 1
                -2 1
                -1 0
                0 0
                0 nan
                0 1
                1 1
                2 0
                3 0
            };
            \legend{default,empty line in table, nan in table + "unbounded coords=jump"}
    \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

BambOo
  • 8,801
  • 2
  • 20
  • 47