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}