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.

Please consider the following MWE. In addition to the xstick of the bottom x-axis (or primary x-axis) I would like to add a extra tick at the upper x-axis (or secondary x-axis).

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfplots,pgfplotstable}
\usetikzlibrary{pgfplots,groupplots}

\begin{document}


\begin{tikzpicture}
    \begin{groupplot}[
        group style={
            group size=2 by 2,
            xlabels at=edge bottom,
            ylabels at=edge left,
    vertical sep= 1.5cm,
    horizontal sep= 2cm,
    every axis y label/.style={at={(ticklabel cs:0.5)},rotate=90,anchor=near ticklabel}
        },
        footnotesize,
        xlabel=xlabel,
        ylabel=very long label
        ,xtick={42,44,46,48}
        ,extra x ticks={41}
        ,extra x tick style={pos=right, grid=major,
        tick label style={pos=left,font=\footnotesize,anchor=north}},
    extra x tick labels={VLP},
]
    \nextgroupplot[title=\#1]
        \addplot[dashed] coordinates{(42, 255) (43, 1584) (44, 1296) (45, 432) (46, 972) (47, 540) (48, 1104) (49, 0)};
        \addplot[blue] coordinates{(41, 608) (42, 608) (43, 1068) (44, 1068) (45, 870) (46, 654) (47,654) (48, 654) (49, 0)};
    \nextgroupplot[title=\#2]
        \addplot[dashed] coordinates{(42, 400) (43, 400) (44, 0) (45, 400) (46, 0) (47, 0) (48, 0) (49, 0)};
        \addplot[blue] coordinates{(41, 267) (42, 267) (43, 267) (44, 200) (45, 200) (46, 0) (47, 0) (48, 0) (49, 0)};
    \nextgroupplot[title=\#3]
        \addplot[dashed] coordinates{(42, 1800) (43, 2100) (44, 1800) (45, 900) (46, 2100) (47, 2100) (48, 2100) (49, 0)};
        \addplot[blue] coordinates{(41, 1613) (42, 1613) (43, 1613) (44, 1613) (45, 1613) (46, 1613) (47, 1613) (48,1613) (49, 0)};
    \nextgroupplot[title=\#4]
        \addplot[dashed] coordinates{(42, 6800) (43, 2800) (44, 2800) (45, 2800) (46, 2000) (47, 2800) (48, 0) (49, 0)};
        \addplot[blue] coordinates{(41, 3600) (42, 3600) (43, 2799) (44, 2789) (45, 2708) (46, 2254) (47, 2254) (48, 0) (49, 0)};
    \end{groupplot}
\end{tikzpicture}


\end{document}  
share|improve this question
5  
You have only an accept rate of 50%. That is rather low. Please visit your questions and upvote helpful answers. Accept the most helpful answer. That will bring more people answering your questions ... –  Kurt Oct 17 '12 at 22:02
    
@Kurt: Many thanks for the tip. Didn't know that. –  John Oct 18 '12 at 13:18
add comment

1 Answer 1

up vote 2 down vote accepted

I don't know how your document could work with that strange preamble (\usetikzlibrary{pgfplots}?). Anyway, you have to set both tick pos and ticklabel pos to right, then there is no need to set the anchor.

\documentclass{article} 

\usepackage{pgfplots} 
\usepgfplotslibrary{groupplots} 
\pgfplotsset{compat=1.6, /pgf/number format/.cd,
             1000 sep={\,}, min exponent for 1000 sep=4}

\begin{document} 


\begin{tikzpicture} 
    \begin{groupplot}[ 
        group style={ 
            group size=2 by 2, 
            xlabels at=edge bottom, 
            ylabels at=edge left, 
            vertical sep=1.5cm, 
            horizontal sep=2cm, 
            every axis ylabel/.append style={at={(ticklabel cs:0.5)}, rotate=90,
                                             anchor=near ticklabel}}, 
        width=0.46\textwidth, 
        xlabel={xlabel}, 
        ylabel={very long label}, 
        xtick={42,44,46,48}, 
        extra x ticks={41},
        extra x tick labels={VLP}, 
        extra x tick style={tick pos=right, grid=major, ticklabel pos=right,
                            tick label style={font=\footnotesize}}     
] 
    \nextgroupplot[title=\#1] 
        \addplot[dashed] coordinates{(42, 255) (43, 1584) (44, 1296) (45, 432)
                                     (46, 972) (47, 540) (48, 1104) (49, 0)}; 
        \addplot[blue] coordinates{(41, 608) (42, 608) (43, 1068) (44, 1068)
                                   (45, 870) (46, 654) (47,654) (48, 654) (49, 0)}; 
    \nextgroupplot[title=\#2] 
        \addplot[dashed] coordinates{(42, 400) (43, 400) (44, 0) (45, 400)
                                     (46, 0) (47, 0) (48, 0) (49, 0)}; 
        \addplot[blue] coordinates{(41, 267) (42, 267) (43, 267) (44, 200)
                                   (45, 200) (46, 0) (47, 0) (48, 0) (49, 0)}; 
    \nextgroupplot[title=\#3] 
        \addplot[dashed] coordinates{(42, 1800) (43, 2100) (44, 1800) (45, 900)
                                     (46, 2100) (47, 2100) (48, 2100) (49, 0)}; 
        \addplot[blue] coordinates{(41, 1613) (42, 1613) (43, 1613) (44, 1613)
                            (45, 1613) (46, 1613) (47, 1613) (48,1613) (49, 0)}; 
    \nextgroupplot[title=\#4] 
        \addplot[dashed] coordinates{(42, 6800) (43, 2800) (44, 2800) (45, 2800)
                                     (46, 2000) (47, 2800) (48, 0) (49, 0)}; 
        \addplot[blue] coordinates{(41, 3600) (42, 3600) (43, 2799) (44, 2789)
                              (45, 2708) (46, 2254) (47, 2254) (48, 0) (49, 0)}; 
    \end{groupplot} 
\end{tikzpicture} 
\end{document}

enter image description here

share|improve this answer
    
I found \usetikzlibrary{pgfplots} in another MWE. Thx for the tip. –  John Oct 19 '12 at 18:54
add comment

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.