如何使用 TikZ 制作如下的能级图?
我见过一些能级图的例子(例如这),但我不确定如何制作一个具有轴的。
答案1
我做过类似的事情作为个人笔记,
代码如下
\begin{center}
\begin{tikzpicture}[thick,line cap=round,yscale=2,
% Styles
axes/.style=,
important line/.style={very thick},
information text/.style={rounded corners,draw=blue!80!black,fill=blue!10,inner sep=1ex}]
\pgfkeys{/pgf/number format/.cd,fixed,precision=2}
\pgfmathsetmacro{\r}{.7}
\pgfmathsetmacro{\R}{.5}
\draw[help lines, color=blue!20,step=1cm] (-.4,-.4) grid (12.3,8.3);
%\draw (0,0) node[anchor=east] {$m_{\text{eff}} =0$} -- (2,0);
\foreach \n in {0,1,2,3} {
\foreach \m in {0,1,...,3} {
\draw[important line,xshift=3*\n cm] (0,{sqrt((\m/\r)^2 + (\n/\R)^2)}) node[anchor=east] {$m_{\text{eff}} = \pgfmathparse{sqrt((\m/\r)^2 + (\n/\R)^2) }\pgfmathprintnumber{\pgfmathresult}$} -- (2,{sqrt((\m/\r)^2 + (\n/\R)^2)});
}
\draw [decorate,decoration={brace,amplitude=10pt,mirror},ultra thick,color=blue,yshift=-4pt,xshift=3*\n cm] (0,0) -- (2,0) node [black,midway,yshift=-0.6cm] { $n=\n$};
}
\end{tikzpicture}
\end{center}
它也许会对你有帮助!
答案2
对于这种自由格式的图表,元帖子通常很合适,因为它只是标签和线条。
关键是要建立合理的水平和垂直单位。您可以考虑编写一个小函数来处理标签和线条,但由于标签和线条不多,而且您可能需要灵活地处理标签的位置,所以这可能不值得。
prologues := 3;
outputtemplate := "%j%c.eps";
beginfig(1);
v = 0.2; % vertical unit 0.2bp = 0.567mm
u = 1cm; % horizontal unit
drawoptions(withcolor .78 red);
xpos := 2u;
draw (left -- right) scaled 1/2u shifted (xpos,+680v); label.top(btex $\Upsilon(4S)$ etex,(xpos,+680v)) withcolor black;
draw (left -- right) scaled 1/2u shifted (xpos,+450v); label.top(btex $\Upsilon(3S)$ etex,(xpos,+450v)) withcolor black;
draw (left -- right) scaled 1/2u shifted (xpos,+120v); label.top(btex $\Upsilon(2S)$ etex,(xpos,+120v)) withcolor black;
draw (left -- right) scaled 1/2u shifted (xpos,-440v); label.top(btex $\Upsilon(1S)$ etex,(xpos,-440v)) withcolor black;
% etc
drawoptions(dashed withdots scaled .5 withcolor .67 blue);
xpos := xpos + 2u;
draw (left -- right) scaled 1/2u shifted (xpos,250v); label.top(btex $\psi(3770)$ etex,(xpos,250v)) withcolor black;
draw (left -- right) scaled 1/2u shifted (xpos,170v); label.top(btex $\psi(2S)$ etex,(xpos,170v)) withcolor black;
draw (left -- right) scaled 1/2u shifted (xpos,105v); label.bot(btex $\eta_k(2S)$ etex,(xpos,105v)) withcolor black;
% etc, etc for the other markers
drawoptions();
draw (1u,-600v) -- (1u,-610v) -- (5u,-610v) -- (5u,-600v) withcolor .62 green;
label.bot(btex $S$ states etex, (3u,-610v));
% axis marker
drawoptions(withcolor .4 white);
draw (0,-580v) -- (0,780v);
for i=-500v step 100v until 700v+epsilon: draw (-1/5u,i)--(0,i); endfor
drawoptions();
label.lft(btex $-500$ etex, (-1/5u,-500v));
label.lft(btex $+500$ etex, (-1/5u,+500v));
label.lft(btex $0$ etex, (-1/5u,0));
label.lft(btex MeV etex, (-1/5u,800v));
endfig;
end.