我怎样才能重现这个情节?
这是目前我的代码。我只想在 x 轴和点上添加相等的线距(k-f_s(k))
。
\documentclass[crop,tikz,convert={outext=.svg,command=\unexpanded{pdf2svg \infile\space\outfile}},multi=false]{standalone}
\usepackage{xcolor}
\definecolor{customPurple}{HTML}{812C7C}
\usepackage{pgfplots}
\pgfplotsset{
every tick label/.append style={font=\footnotesize},
}
\begin{document}
\begin{tikzpicture}[x=1cm,y=1.5cm]
\begin{axis}[
grid=both,
xlabel={Key},
ylabel={Position},
grid style={thin,densely dotted,black!20},
ytick=data,
]
\addplot[only marks, mark size=1.5pt, black] coordinates{
(27,0)
(29,1)
(32,2)
(32,3)
(33,4)
(37,5)
(37,6)
(37,7)
(38,8)
(40,9)
(41,10)
(43,11)
(44,12)
(46,13)
};
% eq: 11y = 8x - 223
\draw[customPurple, thick] (axis cs:27,-0.63) -- (axis cs:46,13.18) ;
\end{axis}
\end{tikzpicture}
\end{document}