1

When plotting a bar chart using the following example, the ticks of the y axis are directed to the inside, the ones of the x axis to the outside. How can I make it so they both show on the inside and outside of the chart?

\documentclass{standalone}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.16} 
\begin{tikzpicture}
 \begin{axis}[ybar,symbolic x coords={A,B,C},xtick={A,B,C}]
     \addplot coordinates{(A,24)(B,25)(C,26)};
     \addplot coordinates{(A,17)(B,19)(C,21)};
 \end{axis}
 \end{tikzpicture}
 \end{document}

enter image description here

  • Hey, and welcome to tex.SX. It generally increases the probability of getting an answer if you post a complete code example (usually \documentclass[tikz]{standalone} ... \begin{document}... etc.) this way we can just copy and paste your code and start playing around with it to find a solution – sheß Mar 6 at 13:17
  • (1) welcome, (2) as always on this site, please post a full minimal example instead of a sniplet like this as it makes it a lot easier for others to test your code. – daleif Mar 6 at 13:18
2

From https://tex.stackexchange.com/a/140937/3929, plus looked up the options for xtick align and guessed that there is also an option that sets both.

\documentclass{standalone}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
    ybar,
    symbolic x coords={A,B,C},
    xtick={A,B,C},
    tick align=center, % <------
    ]
    \addplot coordinates{(A,24)(B,25)(C,26) };
    \addplot coordinates{(A,17)(B,19)(C,21)};
\end{axis}
\end{tikzpicture}
\end{document}
  • @cheesus for a lot of tikz/pgfplots questions, you can get the answer via google and trying to guess what it is called in English. It is highly likely that someone has asked about it before. – daleif Mar 6 at 13:55

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.