ノードの周囲に境界線を描く

ノードの周囲に境界線を描く

添付の図のような図が以下のコードで作成されています。点線の境界画像に示すように、いくつかのノードの周囲に。これを行うための最良の方法は何ですか? ヒントがあれば大歓迎です。ありがとうございます。

\documentclass{article}

\usepackage{tikz}
\usepackage{caption}
\usepackage{pgfplots}
\usepackage{amsmath}
\usepackage{graphicx}

\begin{document}


\begin{figure}
\begin{tikzpicture}
\pgfplotsset{every axis legend/.append style={
at={(0.23,0.74)},
anchor=south}}
\begin{axis}[ xlabel = Field X Axis, ylabel = Field Y Axis  ,  xtick ={0, 50, 100}, ytick ={0, 50, 100}, legend entries ={Node, MC's Position, Base Station}]
\addplot[ gray, only marks] coordinates {(10,15) (10, 60) (2,55) (17, 16) (17,25) (1, 21) (5,45) (83, 10) (56,35) (25, 40)};
\addplot[orange, only marks, mark=square*, mark size=4] coordinates {(0,60) (60,80) (85,15)};
\addplot[cyan, only marks, mark=triangle*, mark size=7] coordinates {(0,5)};

\addplot[no markers, dashed, cyan] coordinates {(0,5) (0, 60)};
\addplot[no markers, dashed, cyan] coordinates {(0,5)(85,15)};
\addplot[no markers, dashed, cyan] coordinates {(0,5) (60,80)};

\end{axis}
\end{tikzpicture}
\caption{System Overview of  WRSN}
\end{figure}



\end{document}

サンプル画像

答え1

1 つの方法は、点線を描きたい座標に名前を付け、選択した座標に合うノードの形状を選択することです。このためには、TikZ ライブラリをfitドキュメントのプリアンブルに追加する必要がありました。

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

\documentclass{article}
\usepackage{caption}
\usepackage{pgfplots}
\pgfplotsset{width=11cm,compat=1.13} % <--- added
\usetikzlibrary{fit,shapes.geometric}% <--- added
\usepackage{amsmath}
\usepackage{graphicx}

% for show figure only
\usepackage[active,floats,tightpage]{preview}
    \setlength\PreviewBorder{1em}

\begin{document}
    \begin{figure}[h]
\begin{tikzpicture}
\pgfplotsset{every axis legend/.append style={
at={(0.23,0.74)},
anchor=south}}
\begin{axis}[ xlabel = Field X Axis, ylabel = Field Y Axis  ,  xtick ={0, 50, 100}, ytick ={0, 50, 100}, legend entries ={Node, MC's Position, Base Station}]
\addplot[ gray, only marks] coordinates {(10,15) (10, 60) (2,55) (17, 16) (17,25) (1, 21) (5,45) (83, 10) (56,35) (25, 40)};
\addplot[orange, only marks, mark=square*, mark size=4] coordinates {(0,60) (60,80) (85,15)};
\addplot[cyan, only marks, mark=triangle*, mark size=7] coordinates {(0,5)};

\addplot[no markers, dashed, cyan] coordinates {(0,5) (0, 60)};
\addplot[no markers, dashed, cyan] coordinates {(0,5)(85,15)};
\addplot[no markers, dashed, cyan] coordinates {(0,5) (60,80)};

%%%% added
\coordinate (a) at (1, 21);
\coordinate (b) at (10,15);
\coordinate (c) at (17,16);
\coordinate (d) at (17,25);
    \node[ellipse, draw, thick, dotted, 
          fit=(a) (b) (c) (d)] {};
%%%%
\end{axis}
\end{tikzpicture}
\caption{System Overview of  WRSN}
    \end{figure}
\end{document}

補遺:座標に名前を付けなくても同じ結果が得られます。

%%%% added
\node[ellipse, draw, thick, dotted, 
      fit={(1, 21) (10,15) (17,16) (17,25)}] {};% <-- field of coordinates are inside {  }
%%%%

関連情報