pgfplot 图形中的大括号

pgfplot 图形中的大括号

我试图在 pgfplot 的某个部分后面放置一个大括号 }。我找不到 pgfplot 构造,所以我尝试使用 \right },在它前面放置一个空的 \frac 表达式以强制它扩展。它确实做到了,但还不够。我在每个表达式前面都添加了一个小的 } 来表明我的目标。它们应该与函数步骤的大小相同。我希望我试图做的事情是清楚的。任何帮助都值得感激。

\documentclass{amsbook}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepgfplotslibrary{fillbetween}
\begin{document}
\begin{figure}
\begin{tikzpicture}
    \begin{axis}
        [
        axis x line =middle, 
        axis y line= middle,    
        xmin=-1, 
        xmax=3, 
        ymin=-0.02,   % It must extend below 0 or the thick lines won't show.
        ymax=1.2,
        x label style={at= {(axis description cs:0.5,-0.15)}},
        xlabel = $k$]
        \addplot[very thick] coordinates {(-1,0) (0,0) };
        \addplot[very thick] coordinates {(0,0.4) (1,0.4)};
        \addplot[mark=*] coordinates {(0,0.4)};
        \addplot[mark=*,fill=white] coordinates {(1,0.4)};
        \draw[dashed] (1,0) -- (1,0.39);
        \draw (1.3,0.2) node[right] {\} $p_K(0;q)$ };
        \draw[very thick] (-0.8,0) -- (0,0);
        \addplot[mark=*, fill=white] coordinates {(0,0)};
        
        \addplot[very thick] coordinates {(1,1) (2,1)};
        \draw(2,1) node[right]{$F_K(k;q)$};
        \addplot[mark=*] coordinates {(1,1)};
        \draw[dashed] (1,0.43) -- (1,1);
        \draw (1.4,0.7) node[right] {$\} p_K(1;q)$};
    \end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

在此处输入图片描述

答案1

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18} 
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle, 
xmin=-1, xmax=3, 
ymin=0, ymax=1.2,
x label style={at= {(axis description cs:0.5,-0.15)}},
xlabel=$k$,
enlargelimits=0.05,
]
\addplot[very thick] coordinates {(-1,0) (0,0)};
\addplot[very thick] coordinates {(0,0.4) (1,0.4)};
\addplot[very thick] coordinates {(1,1) (2,1)};
\addplot[mark=*, fill=white] coordinates {(0,0)};
\addplot[mark=*] coordinates {(0,0.4)};
\addplot[mark=*, fill=white] coordinates {(1,0.4)};
\addplot[mark=*] coordinates {(1,1)};
\draw[dashed] (1,0) -- (1,1);
\draw(2,1) node[right]{$F_K(k;q)$};
\draw[decorate, decoration={brace, amplitude=0.2cm}] (1.2,0.4) --node[right=0.2cm] {$p_K(0;q)$} (1.2,0.0);
\draw[decorate, decoration={brace, amplitude=0.2cm}] (1.4,1.0) --node[right=0.2cm] {$p_K(1;q)$} (1.4,0.4);
\end{axis}
\end{tikzpicture}
\end{document}

带有一些括号的步进图

相关内容