我想用 tikz 画出类似这样的希格斯势场。我不知道如何画出构成势“阴影”的点,有人知道如何帮助我吗?
[编辑:我并不是要求提供绘制电位的整个代码,因为我知道如何做到这一点,但我只想知道如何生成阴影]
[编辑:到目前为止我有这个代码:
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{tzplot}
\begin{document}
\begin{tikzpicture}
\tzaxes(-2.5,-1.5)(2.5,5){$x$}{$y$}
\tzfn[thick]{(-1.2*(\x)^2 +0.4*(\x)^4)}[-2.3:2.3]{$V(x)$}[ar]
\tzfn[black, ->]{(\x)}[2:-2]{$z$}[ar]
\draw[thick, dashed] (1.25,-0.9) arc (0:360:1.25cm and 0.2cm);
\draw[thick] (2.15,3) arc (0:360:2.15cm and 0.5cm);
\end{tikzpicture}
\end{document}
输出结果如下: 。我需要帮助来添加虚线,以便给出阴影的概念]
谢谢!
答案1
您可以使用fillbetween
PGFPlots 提供的库:
\documentclass[border=5mm]{standalone}
\usepackage{tzplot, pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\tzaxes(-2.5,-1.5)(2.5,5){$x$}{$y$}
\tzfn[thick, name path=curve]{(-1.2*(\x)^2+0.4*(\x)^4)}[-2.3:2.3]{$V(x)$}[ar]
\tzfn[black, ->]{(\x)}[2:-2]{$z$}[ar]
\draw[thick, dashed, name path=bottom] (1.25,-0.9)
arc[start angle=0, end angle=360, x radius=1.25cm, y radius=0.2cm];
\draw[thick, name path=top] (2.15,3)
arc[start angle=0, end angle=360, x radius=2.15cm, y radius=0.5cm];
\path[name path=clipped curve, intersection segments={of=top and curve, sequence={R2}}];
\fill[gray, opacity=0.2, intersection segments={of=clipped curve and bottom, sequence={L1}}]
to[out=100, in=180] (0,2.5)
arc[start angle=270, end angle=180, x radius=2.15cm, y radius=0.5cm] -- cycle;
\fill[gray, opacity=0.2, intersection segments={of=clipped curve and bottom, sequence={L5[reverse]}}]
to[out=80, in=0] (0,2.5)
arc[start angle=270, end angle=360, x radius=2.15cm, y radius=0.5cm];
\fill[gray, opacity=0.4, intersection segments={of=clipped curve and bottom, sequence={L3 -- R3}}] -- cycle;
\end{tikzpicture}
\end{document}
正如评论中所建议的,使用图案的变化来模仿点状阴影:
\documentclass[border=5mm]{standalone}
\usepackage{tzplot, pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns.meta}
\begin{document}
\begin{tikzpicture}
\tzaxes(-2.5,-1.5)(2.5,5){$x$}{$y$}
\tzfn[thick, name path=curve]{(-1.2*(\x)^2+0.4*(\x)^4)}[-2.3:2.3]{$V(x)$}[ar]
\tzfn[black, ->]{(\x)}[2:-2]{$z$}[ar]
\draw[thick, dashed, name path=bottom] (1.25,-0.9)
arc[start angle=0, end angle=360, x radius=1.25cm, y radius=0.2cm];
\draw[thick, name path=top] (2.15,3)
arc[start angle=0, end angle=360, x radius=2.15cm, y radius=0.5cm];
\path[name path=clipped curve, intersection segments={of=top and curve, sequence={R2}}];
\fill[
pattern={
Dots[radius=0.4pt, angle=45, distance={2pt/sqrt(2)}]
},
intersection segments={
of={clipped curve and bottom},
sequence={L1}
}
] to[out=100, in=180] (0,2.5)
arc[start angle=270, end angle=180, x radius=2.15cm, y radius=0.5cm] -- cycle;
\fill[
pattern={
Dots[radius=0.4pt, angle=45, distance={2pt/sqrt(2)}]
},
intersection segments={
of={clipped curve and bottom},
sequence={L5[reverse]}
}
] to[out=80, in=0] (0,2.5)
arc[start angle=270, end angle=360, x radius=2.15cm, y radius=0.5cm];
\fill[
pattern={
Dots[radius=0.7pt, angle=45, distance={2pt/sqrt(2)}]
},
intersection segments={
of={clipped curve and bottom},
sequence={L3 -- R3}
}
] -- cycle;
\end{tikzpicture}
\end{document}