
ギャップのある関数のグラフを作成し、下の図のように上の点を穴にする必要があります。手動で小さな円を作成し、上の線を調整して合わせる以外に、これを行う方法はありますか?
これが私のMWEです。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[declare function={sigma(\x)=1/(1+exp(-\x));}]
\begin{axis}
[
grid=major,
xmin=-6,
xmax=6,
axis x line=bottom,
ytick={0,.5,1},
ymax=1,
axis y line=middle,
samples=100,
domain=-6:6,
legend style={at={(1,0.9)}}
]
\draw [dashed,black!50] (1,0.365) -- (1,0.865);
\addplot[very thick,black,mark=none, samples=100,domain=-6:1] (x, {.5 * sigma(x)});
\addplot[very thick,black,mark=none, samples=100,domain=1:6] (x, {.5 + .5 * sigma(x)});
\end{axis}
\end{tikzpicture}
\end{document}
答え1
線を調整してフィットさせるという意味がよくわかりませんが、関数を宣言して、それを使用してプロット、破線、円などすべてを描画します。
pgfplots
を設定することで、最初の点にのみマーカーを描くことができます。mark repeat=N
ここN
で、はサンプル数以上の任意の数です。したがって、次のようにすることができます。
\addplot[very thick,black,mark=*,mark options={fill=white},domain=1:6, mark repeat=1000] {F(x)+0.5};
マーカーを含む後半部分を描画します。F
は で宣言された関数ですdeclare function
。以下のコードを参照してください。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[
declare function={
sigma(\x)=1/(1+exp(-\x));
F(\x) = 0.5 * sigma(\x);
}]
\begin{axis}
[
grid=major,
xmin=-6,
xmax=6,
axis x line=bottom,
ytick={0,.5,1},
ymax=1,
axis y line=middle,
samples=100,
legend style={at={(1,0.9)}}
]
\addplot[very thick,black,mark=none, domain=-6:1] {F(x)};
\addplot[very thick,black,mark=*,mark options={fill=white},domain=1:6, mark repeat=1000] {F(x)+0.5};
\draw [dashed,black!50] (1,{F(1)}) -- (1,{F(1)+0.5});
\end{axis}
\end{tikzpicture}
\end{document}