如何绘制从 (-5, 0.5) 开始到 (5, 1.5) 结束的正弦波图?
\begin{tikzpicture}[scale=0.8]
\begin{axis}[xlabel=$x(t)$, ylabel=$t$, grid=major,xmin=-5
xmax=5, ymin=-2, ymax=2, domain=-5:5]
\addplot[blue, line width=1pt, samples=20]
expression{sin(180*x) ??? };
\end{axis}
\end{tikzpicture}
答案1
看来你喜欢画叠加$0.5 + \sin(x)$
。这个函数pgfplots
是{0.5+sin(180*x)}
:
\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$x(t)$, ylabel=$t$,
grid=major,
xmin=-5, xmax=5,
ymin=-2, ymax=2,
domain=-5:4.5,
samples=201]
\addplot[blue, line width=1pt] {0.5+sin(180*x)};
\end{axis}
\end{tikzpicture}
\end{document}