0

Is there a way to get rid of the xticks between the first and second, and the second and third plots in the groupplot below? Getting rid of the xticks on the inside of each plot (e.g. the ticks extending from 0 upwards) would do.

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots, pgfplotstable}
\usepgfplotslibrary{groupplots}
\pgfplotstableread{
wk  1   2   3
0   2   3   4
1   5   6   7
2   0   0   0
3   5   6   7
}\data
\begin{document}
\begin{tikzpicture}
  \pgfplotsset{group/vertical sep={0cm},
    group/x descriptions at=edge bottom,
  }
  \begin{groupplot}[group style={group size=1 by 3},
                    height=5cm,
                    width=8cm,
                    ybar stacked,
                    xtick=data,
                    ymin=0,
                    xticklabels from table={\data}{wk},
                    tick align=outside
                    ]
    \nextgroupplot
      \addplot [fill=black!60] table [y=1, x expr=\coordindex] {\data};    
      \addplot [fill=black!20] table [y=2, x expr=\coordindex] {\data};
      \addplot [fill=black!40] table [y=3, x expr=\coordindex] {\data};
    \nextgroupplot
      \addplot [fill=black!60] table [y=1, x expr=\coordindex] {\data};    
      \addplot [fill=black!20] table [y=2, x expr=\coordindex] {\data};
      \addplot [fill=black!40] table [y=3, x expr=\coordindex] {\data};
    \nextgroupplot
      \addplot [fill=black!60] table [y=1, x expr=\coordindex] {\data};    
      \addplot [fill=black!20] table [y=2, x expr=\coordindex] {\data};
      \addplot [fill=black!40] table [y=3, x expr=\coordindex] {\data};
\end{groupplot}
\end{tikzpicture}
\end{document}
1

So you are searching for something like this?

% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplotstable}
\usepgfplotslibrary{groupplots}
    \pgfplotstableread{
        wk  1   2   3
        0   2   3   4
        1   5   6   7
        2   0   0   0
        3   5   6   7
    }\data
\begin{document}
\begin{tikzpicture}
    \begin{groupplot}[
        group style={
            group size=1 by 3,
            vertical sep={0cm},
            x descriptions at=edge bottom,
        },
        height=5cm,
        width=8cm,
        ybar stacked,
        xtick=data,
        ymin=0,
        xticklabels from table={\data}{wk},
        tick align=outside,
        table/x expr=\coordindex,
    ]
    \nextgroupplot[
        xtick pos=upper,
    ]
        \addplot [fill=black!60] table [y=1] {\data};
        \addplot [fill=black!20] table [y=2] {\data};
        \addplot [fill=black!40] table [y=3] {\data};

    \nextgroupplot[
        xtick style={
            /pgfplots/major tick length=0pt,
        },
    ]
        \addplot [fill=black!60] table [y=1] {\data};
        \addplot [fill=black!20] table [y=2] {\data};
        \addplot [fill=black!40] table [y=3] {\data};

    \nextgroupplot[
        xtick pos=lower,
    ]
        \addplot [fill=black!60] table [y=1] {\data};
        \addplot [fill=black!20] table [y=2] {\data};
        \addplot [fill=black!40] table [y=3] {\data};
\end{groupplot}
\end{tikzpicture}
\end{document}

image showing the result of above code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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