0

I want to draw a three-dimensional bar chart. I used this MWE code to draw two-dimensionally. Is it possible to draw in 3D like the last photo?

MWE:(Source)

\documentclass{standalone}

\usepackage{pgfplots}

\begin{document}

\pgfplotstableread[row sep=\\,col sep=&]{
    interval    & carT  & carD  & carR \\
    Type A      & 10    & 15    & 20 \\
    Type B      & 8     & 6     & 12 \\
    Type C      & 5     & 8     & 10 \\
    }\mydata

\begin{tikzpicture}
    \begin{axis}[
            ybar,
            bar width=.5cm,
            width=\textwidth,
            height=.5\textwidth,
            legend style={at={(0.5,1)},
                anchor=north,legend columns=-1},
            symbolic x coords={Type A, Type B, Type C},
            xtick=data,
            nodes near coords,
            nodes near coords align={vertical},
            ymin=0,ymax=35,
        ]
        \addplot table[x=interval,y=carT]{\mydata};
        \addplot table[x=interval,y=carD]{\mydata};
        \addplot table[x=interval,y=carR]{\mydata};
        \legend{AA, BB, CC}
    \end{axis}
\end{tikzpicture}

\end{document}

The result is:

enter image description here

I want this output:

enter image description here

  • 1
    I don't know a simple way to do it. But I also don't see a reason why on should want to draw 3-dimensional bars in a 2-dimentional axis. The reason is that you don't add any more information by drawing them in 3d, but only make it harder to read values. In fact if it wouldn't be written that e.g. the first bar has a value of 10, I would have guessed that it is below 10 ... (Please also have a look at chapter 7 of the TikZ manual.) – Stefan Pinnow Mar 08 '21 at 15:55
  • @StefanPinnow, Your explanation was so convincing. I agree with you now! Thanks so much. – Bahman Mirzakhani Mar 08 '21 at 16:16

0 Answers0