我正在寻找一种方法来移动 XRD 图中的参考条,以便能够比较同一轴环境中的两个或多个图,但仅在适用的地方才有参考。
这应该相当于现有的条形移位键,但在条形图的方向上,例如,一种调整条形图或 ycomb 最小值的简单方法。
我的最小示例包含两个分析图和参考,它们只是不同文本文件中的坐标。我想将紫色图向上移动到第二个图。现在它看起来像这样:。
\documentclass[]{article}
\usepackage{textcomp}
\usepackage{chemmacros}
% % % Plotting % % %
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usetikzlibrary{plotmarks}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{figure}[htb]
\centering
\begin{tikzpicture}
\begin{axis}[
width = 14 cm,
height = 6 cm,
xlabel={2$\theta$ (\textdegree)},
axis x line=bottom,
ylabel={intensity (a.\,u.)},
axis y line=left,
tick align=outside,
xmin=10,
xmax=80,
ymin=0,
yticklabels= ,
scaled ticks=false,
]
% XRD
\axispath\draw (500,500) node[anchor=west, green!60!black] {\footnotesize{\ch{La2CuO4} (\#80-0579)}}
(500,450) node[anchor=west, purple] {\footnotesize{\ch{La2O2CO3} (\#48-1113)}}
(0,80) node[anchor=west, black] {\footnotesize{LCO}}
(0,500) node[anchor=west, black] {\footnotesize{post-test}};
%\addplot[black, solid, mark=none] table[header=false, x index={0}, y expr=\thisrowno{1}, skip first n={53}] {fresh.uxd}; % only necessary for the real plots
%\addplot[black, solid, mark=none] table[header=false, x index={0}, y expr=\thisrowno{1}+3000, skip first n={53}] {pt.uxd}; % only necessary for the real plots
% references: PDF files
\addplot[ybar,bar width=0.01pt,green!60!black, fill=green!60!black, ybar legend] table[header=false, x index={0}, y expr=\thisrowno{1}*1.1, skip first n={1}] {01-080-0579_La2CuO4_PDF.dat};
\addplot+[ycomb, solid, mark={}, mark options={purple}, purple] table[header=false, x index={0}, y expr=\thisrowno{1}*4, skip first n={1}] {00-048-1113_La2O2CO3_PDF.dat}; % , yshift=4000, only works in x direction...
%\addplot[ybar, bar width=0.01pt, purple, fill=purple, ybar legend] table[header=false, x index={0}, y expr=\thisrowno{1}*5, skip first n={1}] {\PfadXRD 00-048-1113_La2O2CO3_PDF.dat}; % bar shift=300pt, only works in x direction...
%\addlegendentry[purple]{\ch{La2O2CO3} \footnotesize{(\#48-1113)}}
\end{axis}
\end{tikzpicture}
\label{fig:XRD_MWE}
\end{figure}
\end{document}
有什么方法可以实现这一点而我却忽略了?
编辑2:我删除了数据文件,因为Jake完全回答了这个问题,并从线程中删除了相应的非活动链接。
答案1
您可以通过添加以下内容将整个梳子沿 y 方向移动shift={(axis direction cs:0,4000)}
:
\documentclass[]{article}
\usepackage{textcomp}
\usepackage{chemmacros}
% % % Plotting % % %
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usetikzlibrary{plotmarks}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{figure}[htb]
\centering
\begin{tikzpicture}
\begin{axis}[
width = 14 cm,
height = 6 cm,
xlabel={2$\theta$ (\textdegree)},
axis x line=bottom,
ylabel={intensity (a.\,u.)},
axis y line=left,
tick align=outside,
xmin=10,
xmax=80,
ymin=0,
yticklabels= ,
scaled ticks=false,
]
% XRD
\axispath\draw (500,500) node[anchor=west, green!60!black] {\footnotesize{\ch{La2CuO4} (\#80-0579)}}
(500,450) node[anchor=west, purple] {\footnotesize{\ch{La2O2CO3} (\#48-1113)}}
(0,80) node[anchor=west, black] {\footnotesize{LCO}}
(0,500) node[anchor=west, black] {\footnotesize{post-test}};
\addplot[ycomb, green!60!black, ybar legend] table[header=false, x index=0, y expr=\thisrowno{1}*1.1, skip first n={1}] {01-080-0579_La2CuO4_PDF.dat};
\addplot[ycomb, purple, shift={(axis direction cs:0,4000)}] table[header=false, x index=0, y index=1, skip first n={1}] {00-048-1113_La2O2CO3_PDF.dat}; %
\end{axis}
\end{tikzpicture}
\label{fig:XRD_MWE}
\end{figure}
\end{document}