Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am looking for a way to shift the reference bars in an XRD plot in order to be able to compare two or more plots in the same axis environment but have the references only where they apply.
This should be equivalent to the existing bar shift key but in the direction of the bar plot, e.g. an easy way of adjusting the minimum value of the bar plot or the ycomb.

My minimum example contains two analysis plots and the references which are just coordinates in a different text file. I would want to shift the purple one upwards to the second plot. This is what it looks like now: MWE_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}

Is there any way to achieve this that I have overlooked?

edit2: I took down the data files since Jake wholly answered the question and removed the corresponding inactive links from the thread.

share|improve this question
1  
Welcome to TeX.SX! Have you considered using the y expr to add a value to the purple plot? You can get the value of the first row of a given column and add it to the data you want to shift. See Jake's comment on this question: tex.stackexchange.com/q/94150/32374 –  darthbith Jun 17 at 11:46
1  
I have tried this at first but it only gives a longer ybar/ycomb since it is changing the value itself. To get what I want, I'd really need to change the minimum value of the bar or comb which is set by the axis itself I suppose. –  merci-bien Jun 17 at 12:17
    
Can you post some sample data for us to try? –  darthbith Jun 17 at 14:38
1  
@darthbith: I just added a link to the corresponding data files. –  merci-bien Jun 17 at 14:48

1 Answer 1

up vote 4 down vote accepted

You can shift the whole combs in the y direction by adding 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}
share|improve this answer
    
Great, that is exactly what I was looking for. –  merci-bien Jun 25 at 13:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.