ポリゴンの内側または外側に点を描く (TiKZ)

ポリゴンの内側または外側に点を描く (TiKZ)

こんにちは。私はこのプロットを持っており、座標に赤色で(3,1)2つの点を描画したいと思います。(4,4)

\begin{tikzpicture}
\begin{axis}[
    title={Low capacity scenario (Scenary=2)},
    axis x line=bottom,
    axis y line=left,
    xlabel={arrival/15min},
    ylabel={departure/15min},
    xmin=0, xmax=8,
    ymin=0, ymax=8,
    enlargelimits=false
   ]
   \addplot coordinates {
    (0,0)
    (4,0)
    (4,1)
    (3,3)
    (0,4)
    (0,0)
   }; 
   \legend{maximum capacity}
\end{axis}
\end{tikzpicture}}

どうすればいいですか? すでに作成されたプロット内に 2 つの円形の赤い点だけをプロットするのですか? ご協力ありがとうございます。マニュアルには同様のグラフが見つかりませんでした。

答え1

次の方法で、希望する座標に 2 つのプロットを追加できます。

\addplot[red,mark=*] coordinates {(3,1)};
\addplot[red,mark=*] coordinates {(4,4)};   

または、次のようなオプションを使用して別のプロットを追加しますdraw=none

\addplot[draw=none,red,mark=*] coordinates {
   (3,1)
   (4,4)
   };

同じ でaxis、次の図が得られます。

ここに画像の説明を入力してください

完全なコード:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
\begin{axis}[
    title={Low capacity scenario (Scenary=2)},
    axis x line=bottom,
    axis y line=left,
    xlabel={arrival/15min},
    ylabel={departure/15min},
    xmin=0, xmax=8,
    ymin=0, ymax=8,
    enlargelimits=false
   ]
   \addplot coordinates {
    (0,0)
    (4,0)
    (4,1)
    (3,3)
    (0,4)
    (0,0)
   }; 
   \legend{maximum capacity}
   \addplot[red,mark=*] coordinates {(3,1)};
   \addplot[red,mark=*] coordinates {(4,4)};
\end{axis}
\end{tikzpicture}

\end{document}

答え2

コマンドを使用して追加することも\addplot1 つのオプションですが、自分で円を描くこともできます。バージョン 1.12 がインストールされていて、プリアンブルにpgfplots次の行がある場合は、これで十分です。\pgfplotsset{compat=1.12}

 \pgfplotsset{compat=1.12}
.
.
.
\fill[red] (3,1) circle (2pt);
\fill[red] (4,4) circle (2pt);

1.12 より古いバージョンをお持ちの場合は、次の操作を行ってください。

\fill[red] (axis cs: 3,1) circle (2pt);
\fill[red] (axis cs: 4,4) circle (2pt);

コード:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}

\begin{tikzpicture}
\begin{axis}[
    title={Low capacity scenario (Scenary=2)},
    axis x line=bottom,
    axis y line=left,
    xlabel={arrival/15min},
    ylabel={departure/15min},
    xmin=0, xmax=8,
    ymin=0, ymax=8,
    enlargelimits=false
   ]
   \addplot coordinates {
    (0,0)
    (4,0)
    (4,1)
    (3,3)
    (0,4)
    (0,0)
   };
   \legend{maximum capacity}
   \fill[red] (3,1) circle (2pt);
   \fill[red] (4,4) circle (2pt);
\end{axis}
\end{tikzpicture}

\end{document}

ここに画像の説明を入力してください

関連情報