I am currently trying to make a graph with tikZ, to include it in a LaTeX article. After spending hours, I managed to get something, but not as good as I would like. There is still some problems I don't manage to fix.
My LaTeX code is the following :
Code: Select all
\documentclass[a4paper]{article}
\usepackage{pgfplots}
\usepackage{units}
\pgfplotsset{compat=1.3}% <-- moves axis labels near ticklabels
% (respects tick label widths)
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\tikzset{
every pin/.style={font=\tiny},
}
\begin{axis}[
hide x axis,
axis y line = left,
ylabel = {\(F(J)\) \((\unit{cm^{-1}})\)},
no markers,
xmin = -0.5,
xmax = 11,
ymin = -30,
ymax = 460
]
% Energy lines
\addplot [color=black] coordinates { (0, 0) (2, 0)}; % F(J) = 0
\addplot [color=black] coordinates { (0, 3.84) (2, 3.84)}; % F(J) = 3.84
\addplot [color=black] coordinates { (0, 11.73) (2, 11.73)}; % F(J) = 11.73
\addplot [color=black] coordinates { (0, 23.23) (2, 23.23)}; % F(J) = 23.23
\addplot [color=black] coordinates { (0, 38.63) (2, 38.63)}; % F(J) = 38.63
\addplot [color=black] coordinates { (0, 57.83) (2, 57.83)}; % F(J) = 57.83
\addplot [color=black] coordinates { (0, 80.93) (2, 80.93)}; % F(J) = 80.93
\addplot [color=black] coordinates { (0, 107.83) (2, 107.83)}; % F(J) = 107.83
\addplot [color=black] coordinates { (0, 138.63) (2, 138.63)}; % F(J) = 138.63
\addplot [color=black] coordinates { (0, 173.23) (2, 173.23)}; % F(J) = 173.23
\addplot [color=black] coordinates { (0, 211.63) (2, 211.63)}; % F(J) = 211.63
\addplot [color=black] coordinates { (0, 253.93) (2, 253.93)}; % F(J) = 253.93
\addplot [color=black] coordinates { (0, 300.03) (2, 300.03)}; % F(J) = 300.03
\addplot [color=black] coordinates { (0, 353.83) (2, 353.83)}; % F(J) = 353.83
\addplot [color=black] coordinates { (0, 407.63) (2, 407.63)}; % F(J) = 407.63
% Energy lines descriptions
\node[coordinate,pin=-7:{ ~0~~~~~~~1~~~~~~~~~1.00~~~~~~~~~1.00~~~~3.84}] at (axis cs:2,0) {}; % F(J) = 0
\node[coordinate,pin=-3:{ ~1~~~~~~~3~~~~~~~~~0.981~~~~~~~~2.94~~~7.69}] at (axis cs:2,3.84) {}; % F(J) = 3.84
\node[coordinate,pin=3: { 2~~~~~~~5~~~~~~~~~0.945~~~~~~~~4.73~~~11.5}] at (axis cs:2,11.73) {}; % F(J) = 11.73
\node[coordinate,pin=3: { 3~~~~~~~7~~~~~~~~~0.893~~~~~~~~6.25~~~15.4}] at (axis cs:2,23.23) {}; % F(J) = 23.23
\node[coordinate,pin=0: { 4~~~~~~~9~~~~~~~~~0.828~~~~~~~~7.45~~~19.2}] at (axis cs:2,38.63) {}; % F(J) = 38.63
\node[coordinate,pin=0: { 5~~~~~~11~~~~~~~~0.754~~~~~~~~8.29~~~23.1}] at (axis cs:2,57.83) {}; % F(J) = 57.83
\node[coordinate,pin=0: { 6~~~~~~13~~~~~~~~0.673~~~~~~~~8.75~~~26.9}] at (axis cs:2,80.93) {}; % F(J) = 80.93
\node[coordinate,pin=0: { 7~~~~~~15~~~~~~~~0.590~~~~~~~~8.85~~~30.8}] at (axis cs:2,107.83) {}; % F(J) = 107.83
\node[coordinate,pin=0: { 8~~~~~~17~~~~~~~~0.507~~~~~~~~8.62~~~34.6}] at (axis cs:2,138.63) {}; % F(J) = 138.63
\node[coordinate,pin=0: { 9~~~~~~19~~~~~~~~0.428~~~~~~~~8.13~~~38.4}] at (axis cs:2,173.23) {}; % F(J) = 173.23
\node[coordinate,pin=0: {10~~~~~~21~~~~~~~~0.355~~~~~~~~7.46~~~42.3}] at (axis cs:2,211.63) {}; % F(J) = 211.63
\node[coordinate,pin=0: {11~~~~~~23~~~~~~~~0.288~~~~~~~~6.62~~~46.1}] at (axis cs:2,253.93) {}; % F(J) = 253.93
\node[coordinate,pin=0: {12~~~~~~25~~~~~~~~0.230~~~~~~~~5.75~~~50.0}] at (axis cs:2,300.03) {}; % F(J) = 300.03
\node[coordinate,pin=0: {13~~~~~~27~~~~~~~~0.180~~~~~~~~4.86~~~53.8}] at (axis cs:2,353.83) {}; % F(J) = 353.83
\node[coordinate,pin=0: {14~~~~~~29~~~~~~~~0.138~~~~~~~~4.00~~~57.7}] at (axis cs:2,407.63) {}; % F(J) = 407.63
% Legend
\node[coordinate,pin=0:{{~\(J\)~~~\(2J+1\)~~~\(\exp(\frac{-E_r}{kT})\)~~~\(\frac{N_J}{N_0}\)~~~\(\tilde{v} (\unit{cm})\)}} ] at (axis cs:2,440) {};
\end{axis}
\end{tikzpicture}
\caption{Rotational term values \(F(J)\) (horizontal lines), relative
populations \(\nicefrac{N_j}{N_0}\) and transition wavenumbers
\(\tilde{v}\) of CO [Ref XXX].}
\end{figure}
\end{document}
The problems I have are :
1) Texts are not aligned.
2) Left to the "table" legend, there is a line I don't want.
May anyone help me ?
Thanks a lot !
Hadrien Theveneau
Edit by localghost: Preferably no external links (see Board Rules). Attachments go onto the forum server where possible.