繪製資料時如何避免連接圖表中的不連續點?

繪製資料時如何避免連接圖表中的不連續點?

我想繪製一個具有不連續性的圖表,即它在某一點從 180 度跳到 -180 度。不幸的是,180 和-180 處的點相連。參見下圖。
(現在您可能已經猜到我正在嘗試繪製衛星地面軌道的經緯度圖。)

繪製 MWE:
根據 MWE 繪製

用真實數據繪製:
在此輸入影像描述

我怎麼能夠自動地避開連接這兩點的線?

下面提供了 MWE。

\documentclass{scrartcl}

\usepackage{mwe}
\usepackage{pgfplots}
    \pgfplotsset{compat=1.7}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[%
            ytick={-90,-45,...,90},
            xtick={-180,-135,...,180},
            axis equal,
            grid,
            enlargelimits=false,]
        \addplot+[mark=,] table  {
            % A few points read off from above by eye...
              87   0
             100  75
             135  80
             180  82
            -180  82
            -135  75
             -90  35
             -45 -75
               0 -82
              45 -75
              90 -35
             100   0
        };
    \end{axis}
    \end{tikzpicture}
\end{document}

答案1

只需插入一個空行來中斷路徑

\documentclass{scrartcl}

\usepackage{mwe}
\usepackage{pgfplots}
    \pgfplotsset{compat=1.7}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[%
            ytick={-90,-45,...,90},
            xtick={-180,-135,...,180},
            axis equal,
            grid,
            enlargelimits=false,]
        \addplot+[mark=,] table  {
            % A few points read off from above by eye...
              87   0
             100  75
             135  80
             180  82

            -180  82
            -135  75
             -90  35
             -45 -75
               0 -82
              45 -75
              90 -35
             100   0
        };
    \end{axis}
    \end{tikzpicture}
\end{document}

使用已刪除答案中的 Harish Kumar 的圖像:

在此輸入影像描述

相關內容