我怎样才能画出 25 条水平线来代替这 25 条标记的样本?

我怎样才能画出 25 条水平线来代替这 25 条标记的样本?

mark=-我希望有水平线axis从左到右填满整个区域,而不是通过 标记的样本。我曾想过通过 调整破折号mark size=6cm,但我不知道如何在图的边界处剪切它们。

图片

在此处输入图片描述

平均能量损失

\documentclass[a4paper
]{scrartcl}

\usepackage{
tikz,
pgfplots,
amsmath
}

\usepackage[T1]{fontenc}
\usepackage{
lmodern,
textcomp,
siunitx
}

\begin{document}
\begin{center}
\begin{tikzpicture}[font=\small]
\begin{axis}[
height=5cm,
width=6cm,
scale only axis=true,
%
xlabel={\(\alpha\) in \si{\degree}},
ylabel={\(\sin{(\alpha)}\)},
%
xtick=\empty, ytick=\empty, xticklabels={,,}, yticklabels={,,}, xmajorgrids={false}, ymajorgrids={false}
]
\addplot+[domain=0:360, samples=25, only marks, mark=-] {sin(x)};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}

答案1

在此处输入图片描述

\documentclass[a4paper]{scrartcl}

\usepackage{
tikz,
pgfplots,
amsmath
}

\usepackage[T1]{fontenc}
\usepackage{
lmodern,
textcomp,
siunitx
}

\begin{document}
\begin{center}
\begin{tikzpicture}[font=\small]
\begin{axis}[
height=5cm,
width=6cm,
scale only axis=true,
%
xlabel={\(\alpha\) in \si{\degree}},
ylabel={\(\sin{(\alpha)}\)},
%
xtick=\empty, ytick=\empty, xticklabels={,,}, yticklabels={,,}, xmajorgrids={false}, ymajorgrids={false},
after end axis/.code={
\foreach \i in {90,105,...,270} {% to avoid duplicated lines
\pgfmathparse{sin(\i)} ;
\draw(axis cs:\pgfkeysvalueof{/pgfplots/xmin},\pgfmathresult)--(axis cs:\pgfkeysvalueof{/pgfplots/xmax},\pgfmathresult) ;} ;
}
}
]
\addplot+[domain=0:360, samples=25, only marks, mark=-] {sin(x)};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}

相关内容