我该如何解决绘制此 CDF 图表时遇到的这个问题?

我该如何解决绘制此 CDF 图表时遇到的这个问题?

图表未按预期工作,我收到以下错误代码:!包 pgfkeys 错误:我不知道密钥“/tikz/discontinuous”,我将忽略它。也许您拼错了。请参阅 pgfkeys 包文档以获取解释。输入 H 可立即获得帮助……\end{axis}

我的代码如下。

\documentclass[]{article}

\usepackage{pgfplotstable}
\usepackage{pgfplots}

\begin{document} 
The C.D.F is as follows:

\[F(x)=
\begin{dcases}
0&\text{$x<1$}\\
\frac{11}{36}&\text{$1\leq x<2$}\\
\frac{20}{36}&\text{$2\leq x<3$}\\
\frac{27}{36}&\text{$3\leq x<4$}\\
\frac{32}{36}&\text{$4\leq x<5$}\\
\frac{35}{36}&\text{$5\leq x<6$}\\
1&\text{$x\geq 6$}\\
\end{dcases}
\]

The C.D.F can be graphed as follows:

{\centering
\begin{tikzpicture}
\begin{axis}[
clip=false,
jump mark left,
ymin=0,ymax=1,
xmin=0, xmax=5,
every axis plot/.style={very thick},
discontinuous,
table/create on use/cumulative distribution/.style={
    create col/expr={\pgfmathaccuma + \thisrow{f(x)}}   
}
]
\addplot [red] table [y=cumulative distribution]{
x f(x)
0 0
1 11/36
2 20/36
3 27/36
4 32/36
5 35/36
6 1
};
\end{axis}
\end{tikzpicture}
\par}
\end{document}

答案1

只是阐明 Henri Menke 所说的话。我很乐意删除此答案。请注意,您可以考虑更改几件事,例如使用figure。我按照 Henri Menke 的建议删除了 ,这不是标准样式,discontinuous以及xminxmax和。yminymax

\documentclass[]{article}
\usepackage{amsmath,mathtools}
\usepackage{pgfplotstable}
\usepackage{pgfplots}

\begin{document} 
The C.D.F is as follows:
\[F(x)=
\begin{dcases}
0&\text{$x<1$}\\
\frac{11}{36}&\text{$1\leq x<2$}\\
\frac{20}{36}&\text{$2\leq x<3$}\\
\frac{27}{36}&\text{$3\leq x<4$}\\
\frac{32}{36}&\text{$4\leq x<5$}\\
\frac{35}{36}&\text{$5\leq x<6$}\\
1&\text{$x\geq 6$}\\
\end{dcases}
\]

The C.D.F can be graphed as follows:
\begin{center}
\begin{tikzpicture}
\begin{axis}[
clip=false,
jump mark left,
%ymin=0,ymax=1,
%xmin=0, xmax=5,
every axis plot/.style={very thick},
%discontinuous,
table/create on use/cumulative distribution/.style={
    create col/expr={\pgfmathaccuma + \thisrow{f(x)}}   
}
]
\addplot [red] table [y=cumulative distribution]{
x f(x)
0 0
1 11/36
2 20/36
3 27/36
4 32/36
5 35/36
6 1
};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}

在此处输入图片描述

相关内容