我已经设法画出这个东西,我发现它非常好(如果它不是那么简单,我很抱歉,但我试图缩小它并遇到同样的问题,但它有点混乱......):
\documentclass[11pt]{article}
%
\usepackage[textwidth=16cm]{geometry}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{pgfplots}\pgfplotsset{compat=1.9}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\usepackage[customcolors]{hf-tikz}
\begin{document}
\newcommand{\splat}{\phantom{\bigg|}}
\begin{equation}
H(\omega) = \frac{\vec{v_o}}{\vec{v_i}} =
\hfsetfillcolor{green!10}\hfsetbordercolor{green}
\tikzmarkin{bp-c}(0,0.6)(0,-0.4)\frac{1}{10}\tikzmarkend{bp-c}\;\;
\frac
{\hfsetfillcolor{blue!10}\hfsetbordercolor{blue}
\tikzmarkin{bp-z}(0,0.6)(0,-0.3) 1+j\splat\dfrac{\omega}{{10^6}}\tikzmarkend{bp-z}}
{\hfsetfillcolor{red!10}\hfsetbordercolor{red}
\tikzmarkin{bp-p}(0,0.5)(0,-0.4) 1+j\splat\dfrac{\omega}{{5\cdot10^6}}\tikzmarkend{bp-p}}
\end{equation}
\noindent\begin{tikzpicture}[remember picture]
\begin{axis}[
width=14cm, height=9cm,
xmode=log,
xmin=1e5, xmax=1e9,
domain=1e5:1e9, samples=200,
ymin=-40, ymax=20,
grid=both,
major grid style={black!50},
xlabel = {angular frequency, $\omega$ (rad/s)},
ylabel = {$||H(\omega)||$ (dB)},
ytick = {-40,-20, 0, 20},
legend style = {nodes=right},
]
\addplot[thick, green] {-20};
\addplot[thick, blue] {x<1e6 ? 0 : 20*log10(x/1e6)};
\addplot[thick, red] {x<5e6 ? 0 : -20*log10(x/5e6)};
\addplot[ultra thick, densely dashed, black]
{x<1e6 ? -20 : (x <5e6 ? -20 + 20*log10(x/1e6) : -20 + 20*log10(x/1e6) - 20*log10(x/5e6)};
\legend{$1/10$, $1+j\omega/{10^6}$, $(1+j\omega/{5\cdot10^6})^{-1}$, total}
\coordinate (line-c) at (axis cs: 2e6, -20);
\coordinate (line-z) at (axis cs: 2e6, 6);
\coordinate (line-p) at (axis cs: 6e6, -2);
\end{axis}
\end{tikzpicture}%
\begin{tikzpicture}[
remember picture, overlay, draw opacity=0.5,>=latex, shorten >=4pt]
\begin{pgfonlayer}{background}
\path[red] (bp-p) ++(4em, 0) edge[thick, ->, bend left] (line-p);
\path[green] (bp-c) ++(0.5em, 0) edge[thick, ->, bend left] (line-c);
%%% this one should go in background
\path[blue] (bp-z) ++(0,3ex) edge[thick, ->, bend right] (line-z);
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
结果如下:
正如你所见,我尝试在这个答案在背景中有箭头(特别是蓝色箭头),但无济于事。
有没有简单的方法让蓝线以下等式?
附言:我尝试过tikzmarks
最新发布,绘制箭头前方程式,但似乎hf-tikz
使用了其自己的标记定义,并且只有在定义后才能使用。所以我放弃了......
答案1
据我所知,pgflayers 位于当前 tikzpicture 的本地。所以我认为不可能在方程的背景中出现蓝色边缘。但我会改变这条边的路径,使其不与方程相交。例如
\path[blue] (bp-z) ++(0,3ex) edge[thick, ->,out=175,in=150,looseness=2.5] (line-z);
结果是
代码:
\documentclass[11pt]{article}
%
\usepackage[textwidth=16cm]{geometry}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{pgfplots}\pgfplotsset{compat=1.9}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\usepackage[customcolors]{hf-tikz}
\begin{document}
\newcommand{\splat}{\phantom{\bigg|}}
\begin{equation}
H(\omega) = \frac{\vec{v_o}}{\vec{v_i}} =
\hfsetfillcolor{green!10}\hfsetbordercolor{green}
\tikzmarkin{bp-c}(0,0.6)(0,-0.4)\frac{1}{10}\tikzmarkend{bp-c}\;\;
\frac
{\hfsetfillcolor{blue!10}\hfsetbordercolor{blue}
\tikzmarkin{bp-z}(0,0.6)(0,-0.3) 1+j\splat\dfrac{\omega}{{10^6}}\tikzmarkend{bp-z}}
{\hfsetfillcolor{red!10}\hfsetbordercolor{red}
\tikzmarkin{bp-p}(0,0.5)(0,-0.4) 1+j\splat\dfrac{\omega}{{5\cdot10^6}}\tikzmarkend{bp-p}}
\end{equation}
\noindent\begin{tikzpicture}[remember picture]
\begin{axis}[
width=14cm, height=9cm,
xmode=log,
xmin=1e5, xmax=1e9,
domain=1e5:1e9, samples=200,
ymin=-40, ymax=20,
grid=both,
major grid style={black!50},
xlabel = {angular frequency, $\omega$ (rad/s)},
ylabel = {$||H(\omega)||$ (dB)},
ytick = {-40,-20, 0, 20},
legend style = {nodes=right},
]
\addplot[thick, green] {-20};
\addplot[thick, blue] {x<1e6 ? 0 : 20*log10(x/1e6)};
\addplot[thick, red] {x<5e6 ? 0 : -20*log10(x/5e6)};
\addplot[ultra thick, densely dashed, black]
{x<1e6 ? -20 : (x <5e6 ? -20 + 20*log10(x/1e6) : -20 + 20*log10(x/1e6) - 20*log10(x/5e6)};
\legend{$1/10$, $1+j\omega/{10^6}$, $(1+j\omega/{5\cdot10^6})^{-1}$, total}
\coordinate (line-c) at (axis cs: 2e6, -20);
\coordinate (line-z) at (axis cs: 2e6, 6);
\coordinate (line-p) at (axis cs: 6e6, -2);
\end{axis}
\begin{scope}[
overlay, draw opacity=0.5,>=latex, shorten >=4pt]
\begin{pgfonlayer}{background}
\path[red] (bp-p) ++(4em, 0) edge[thick, ->, bend left] (line-p);
\path[green] (bp-c) ++(0.5em, 0) edge[thick, ->, bend left] (line-c);
%%% this one should go in background
\path[blue] (bp-z) ++(0,3ex) edge[thick, ->,out=175,in=150,looseness=2.5] (line-z);
\end{pgfonlayer}
\end{scope}
\end{tikzpicture}
\end{document}
请注意,图层的代码与将红色箭头放在图例后面的代码background
处于相同的环境中。tikzpicture
axis
正如你在评论中所建议的那样,也可以使用装饰来中断蓝色边缘。使用
\usetikzlibrary{decorations.pathmorphing}
\tikzset{
continuous/.style 2 args={
postaction={draw,solid, decorate,
decoration={moveto,
pre=curveto, pre length=#1*\pgfdecoratedremainingdistance,
post=curveto, post length=#2*\pgfdecoratedremainingdistance
}}}}
和
\path[blue] (bp-z) ++(0,3ex)edge[draw=none,thick, ->, bend right,
continuous={0.08}{0.65}% first 8% and last 65% are drawn
](line-z);
结果是
代码:
\documentclass[11pt]{article}
\usepackage[textwidth=16cm]{geometry}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{pgfplots}\pgfplotsset{compat=1.9}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\usepackage[customcolors]{hf-tikz}
\usetikzlibrary{decorations.pathmorphing}
\tikzset{
continuous/.style 2 args={%
postaction={draw,solid, decorate,
decoration={moveto,
pre=curveto, pre length=#1*\pgfdecoratedremainingdistance,
post=curveto, post length=#2*\pgfdecoratedremainingdistance
}}}}
\begin{document}
\newcommand{\splat}{\phantom{\bigg|}}
\begin{equation}
H(\omega) = \frac{\vec{v_o}}{\vec{v_i}} =
\hfsetfillcolor{green!10}\hfsetbordercolor{green}
\tikzmarkin{bp-c}(0,0.6)(0,-0.4)\frac{1}{10}\tikzmarkend{bp-c}\;\;
\frac
{\hfsetfillcolor{blue!10}\hfsetbordercolor{blue}
\tikzmarkin{bp-z}(0,0.6)(0,-0.3) 1+j\splat\dfrac{\omega}{{10^6}}\tikzmarkend{bp-z}}
{\hfsetfillcolor{red!10}\hfsetbordercolor{red}
\tikzmarkin{bp-p}(0,0.5)(0,-0.4) 1+j\splat\dfrac{\omega}{{5\cdot10^6}}\tikzmarkend{bp-p}}
\end{equation}
\noindent\begin{tikzpicture}[remember picture]
\begin{axis}[
width=14cm, height=9cm,
xmode=log,
xmin=1e5, xmax=1e9,
domain=1e5:1e9, samples=200,
ymin=-40, ymax=20,
grid=both,
major grid style={black!50},
xlabel = {angular frequency, $\omega$ (rad/s)},
ylabel = {$||H(\omega)||$ (dB)},
ytick = {-40,-20, 0, 20},
legend style = {nodes=right},
]
\addplot[thick, green] {-20};
\addplot[thick, blue] {x<1e6 ? 0 : 20*log10(x/1e6)};
\addplot[thick, red] {x<5e6 ? 0 : -20*log10(x/5e6)};
\addplot[ultra thick, densely dashed, black]
{x<1e6 ? -20 : (x <5e6 ? -20 + 20*log10(x/1e6) : -20 + 20*log10(x/1e6) - 20*log10(x/5e6)};
\legend{$1/10$, $1+j\omega/{10^6}$, $(1+j\omega/{5\cdot10^6})^{-1}$, total}
\coordinate (line-c) at (axis cs: 2e6, -20);
\coordinate (line-z) at (axis cs: 2e6, 6);
\coordinate (line-p) at (axis cs: 6e6, -2);
\end{axis}
\begin{scope}[
remember picture, overlay, draw opacity=0.5,>=latex, shorten >=4pt]
\begin{pgfonlayer}{background}
\path[red] (bp-p) ++(4em, 0) edge[thick, ->, bend left] (line-p);
\path[green] (bp-c) ++(0.5em, 0) edge[thick, ->, bend left] (line-c);
%%% this one should go in background
\path[blue] (bp-z) ++(0,3ex)edge[draw=none,thick, ->, bend right,
continuous={0.08}{0.65}% first 8% and last 65% are drawn
](line-z);
\end{pgfonlayer}
\end{scope}
\end{tikzpicture}
\end{document}