我的第一个目标是绘制类似这些图像的正弦图:
这是我所做的(类似于该论坛中的一个代码):
我想知道的是(如果可能的话)如何将域中的积分数更改为弧度表示,减小其中一个正弦波的幅度,标记信号(V 和 I)、域轴(\theta = wt
)和垂直轴,并使用峰值(Vm
,Im
)而不是垂直轴上的数字。
以下是代码:
\documentclass[11pt]{article}
\usepackage{color}
\usepackage{tikz} % for flowcharts
%\usepackage[latin1]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
trig format plots=rad,
axis lines = middle,
enlargelimits,
clip=false]
\addplot[domain=-2*pi:2*pi,samples=200, red] {sin(x)};
\addplot[domain=-2*pi:2*pi,samples=200, blue, dashed] {sin(x-1)};
\draw[dotted,blue!40] (axis cs: 0,1.1) -- (axis cs: 0,0);
\draw[dotted,red!40] (axis cs: 1,1.1) -- (axis cs: 1,0);
\draw[dashed,olive,<->] (axis cs: 0,1.1) -- node[above,text=black,font=\footnotesize]{$\phi$} (axis cs: 1,1.1);
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
此致。
答案1
好吧,问题太多了,我很困……
\documentclass[11pt]{article}
\usepackage{color}
\usepackage{tikz} % for flowcharts
%\usepackage[latin1]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
width=\linewidth,
trig format plots=rad,
axis lines = middle,
xlabel={$\theta=wt$},
xlabel style={at={(1,0.5)},anchor=west},
enlargelimits,
ytick={\empty},
extra y ticks={1,0.5,0,-0.5,-1},
extra y tick labels={$V_m$,$I_m$,0,$-I_m$,$-V_m$},
xtick={-6.28318, -4.7123889, ..., 6.28318},
xticklabels={
$-2\pi$, $-\frac{3\pi}{2}$, $-\pi$, $\frac{\pi}{2}$, ,
$\frac{\pi}{2}$, $\pi$, $\frac{3\pi}{2}$, $2\pi$},
clip=false]
\addplot[domain=-2*pi:2*pi,samples=200, red] {0.5*sin(x)};
\addplot[domain=-2*pi:2*pi,samples=200, blue, dashed] {sin(x-2)};
\draw[dotted,blue!40] (axis cs: 0,1.1) -- (axis cs: 0,0);
\draw[dotted,red!40] (axis cs: 1,1.1) -- (axis cs: 1,0);
\draw[dashed,olive,<->] (axis cs: 0,1.1) --
node[above,text=black,font=\footnotesize]{$\phi$} (axis cs: 1,1.1);
\coordinate (P) at (axis cs:1.5*pi,{sin(25)});
\node (labelV) at (axis cs:2*pi,{1+sin(2*pi)}) {Voltage $(V)$};
\draw [red!50!black, thick, dashed, ->, shorten >=2pt] (labelV) -- (P);
\coordinate (Q) at (axis cs:-1.5*pi,{sin(30)});
\node (labelI) at (axis cs:-2*pi,{1+sin(2*pi)}) {Current $(I)$};
\draw [red!50!black, thick, dashed, ->, shorten >=2pt] (labelI) -- (Q);
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}