다각형 내부 또는 외부에 점 그리기(TiKZ)

다각형 내부 또는 외부에 점 그리기(TiKZ)

안녕하세요. 저는 이 플롯을 갖고 있으며 좌표에 빨간색으로 (3,1)두 점을 그리고 싶습니다 .(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}}

어떻게 해야 합니까? 이미 완료된 플롯 안에 두 개의 원형 빨간색 점만 플롯합니까? 도와 줘서 고맙다. 매뉴얼에서 비슷한 그래프를 찾을 수 없었습니다.

답변1

다음과 같이 원하는 좌표에 두 개의 플롯을 추가할 수 있습니다.

\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

명령 을 통해 추가하는 것도 \addplot하나의 옵션이지만 언제든지 직접 원을 그릴 수 있습니다. 버전 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}

여기에 이미지 설명을 입력하세요

관련 정보