答案1
使用 pgfplots 会容易得多。
\documentclass[tikz,border=3.14pt]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[scale=0.1]
\draw[thick,-latex] (0,0) -- (115,0) node[below] {marks};
\draw[thick,-latex] (0,0) -- (0,105) node[left] {students};
\xdef\Lst{(20,0)}
\xdef\oldY{0}
\foreach \Y [count=\X] in {14,6,10,20,30,8,12}
{\pgfmathtruncatemacro{\newX}{10*(\X+2)}
\pgfmathsetmacro{\newY}{\oldY+\Y}
\draw[thick,decoration=brace,decorate] (-1,\oldY) -- (-1,\newY)
node[midway,left]
{\Y~};
\draw[dotted] (0,\newY) -- (\newX,\newY);
\draw[dotted] (\newX,\newY) -- (\newX,0) node[below]{\newX};
\xdef\oldY{\newY}
\xdef\Lst{\Lst (\newX,\newY)}
}
\xdef\Lst{\Lst}
\draw[blue,thick,smooth] (0,0) -- plot[smooth,tension=0.3] coordinates \Lst
-- (110,100);
\end{tikzpicture}
\end{document}
答案2
PSTricks 解决方案只是为了好玩。
\documentclass[pstricks]{standalone}
\usepackage{pst-plot,filecontents}
\begin{filecontents*}{test.data}
30 0
40 14
50 20
60 30
70 50
80 80
90 88
100 100
\end{filecontents*}
\newpsstyle{mygrid}
{
Dy=10,
Dx=5,
Ox=30,
tickwidth=1.2pt,
subticksize=1,
xsubticks=5,
ysubticks=5,
subtickcolor=gray,
subtickwidth=.8pt,
xAxisLabel=\huge Marks,
xAxisLabelPos={c,-5},
yAxisLabel=\huge Cumulative Frequency,
yAxisLabelPos={-5,c},
llx=-2,
lly=-2,
urx=1,
ury=1,
}
\readdata{\mydata}{test.data}
\begin{document}
\begin{psgraph}[style=mygrid,xticksize=0 100,yticksize=0 70](30,0)(100,100){15cm}{20cm}
\listplot[plotstyle=cspline,linecolor=red,linewidth=2.4pt,showpoints]{\mydata}
\end{psgraph}
\end{document}