我正在尝试做这样的事情:
将从网上收集的一些代码放在一起却无济于事!
\documentclass{standalone}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{trig format plots=rad}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}[
% /pgfplots/y=2cm, /pgfplots/x=0.1mm % To make sure all the plots use the same scale
]
%%%%%%
\begin{axis}[
anchor=origin,
rotate around={0:(current axis.origin)},
xmin=0, ymin=0, clip=false, % We only want the positive y axis, hence `ymin=0`. `clip=false` is necessary so we can still see the negative component
axis lines*=center, % Axis lines going through the origin
xtick=\empty, ytick=\empty, % No tick marks
enlarge y limits={upper, value=5} % Make the y axis a bit longer than necessary
]
\addplot [thick, red, domain=0.4*pi:0.5*pi,samples= 200] {(cos(5*x^2)*exp(-(x-1.4*pi)^2/0.3)};
\end{axis} %{(cos(5*x^2)*exp(-(x-1.4*pi)^2/0.3)};
%%%%%
\begin{axis}[
hide axis,
%grid
]
\addplot [ultra thick, magenta, domain=-0.2*pi:0.15*pi,samples= 100] {9*sin(5*x)+30};
\addplot [ thick, blue, domain=-0.05*pi:0.05*pi,samples= 300] {(3*cos(25*x)^2*exp(-x^2/0.01)-9};
\end{axis}
\end{tikzpicture}
\end{document}
有什么建议吗?提前谢谢
答案1
let
以下是使用坐标和交点语法以某种方式自动化进行计算的答案:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections,calc}
\begin{document}
\begin{tikzpicture}[scale=2]
\draw[->] (0,0)--(4,0) node[below] {$t$};
\path[name path=Vert,draw,->] (4.5,1)--(4.5,3) node[below,rotate=90] {$\Delta p(r,t)$};
\path[draw,name path=Horiz,->] (0,0)--(0,1.5) node[midway,left] (A){};
\node[rotate=90,font=\small] at (A) {XUV-Something};
\draw[thick,name path=Func,draw,domain=-0.2:2.25,smooth,variable=\x,samples=50] plot ({\x},{2.3-0.7*sin(\x/2.7*360)});
\node[font=\small] at (0.8,2.3) {$eA_{THz}(t)$};
\foreach \WaveL[count=\i from 0] in {0.03,0.06,0.57,0.07,1.1,0.18,0.24,0.02}{
\path[name path=Vert\i] ({1+\i*0.15/2},0)--({1+\i*0.15/2},6);
\path[name intersections={of=Func and Vert\i}] node at (intersection-1)(PointA\i){};
\path[name path=Horiz\i] let \p1=(PointA\i) in(\x1,\y1)--(4.5,\y1) node[inner sep=0] (PointB\i){};
\node (SWav\i) at ($(PointB\i)-(\WaveL,0)$){} ;
\ifnum\i>0
\pgfmathsetmacro\ev{\i/2-int(\i/2)}
\ifdim\ev pt=0.0 pt %
\draw[dotted] (PointA\i)--({1+\i*0.15/2},\WaveL);
\draw[dotted] (PointA\i)--($(PointB\i)-(\WaveL,0)$);
\fi
\fi
\coordinate (Wav\i) at ({1+\i*0.15/2},\WaveL);
}
\draw[blue,thick] plot[smooth] coordinates {(Wav0)(Wav1)(Wav2)(Wav3)(Wav4)(Wav5)(Wav6)(Wav7)};
\draw[red,thick] plot[smooth] coordinates {(SWav0)(SWav1)(SWav2)(SWav3)(SWav4)(SWav5)(SWav6)(SWav7)};
\end{tikzpicture}
\end{document}
输出:
如果我的问题符合您的要求,请更改您的标题,因为它实际上不是旋转,而且一般不能通过旋转来绘制,因为如果我们不是从水平到垂直的“45 度反射”,距离就会发生变化,正如您在我的图中所看到的。