# Cylindrical Bar Chart

I know this might be a long shot, but does anyone happen to know (or point me to where to start) how to draw this chart. Say we have 6 values (5, 10, 15, 20, 25, 30), one for each column.

Thanks in advance!

• Where is the chart? They are cylinders on a plate. Do they actually represent anything? – percusse Aug 11 '14 at 7:51
• An ybar plot with pgfplots would be several orders of magnitude easier to understand than this example... For graphs often less is better. – s__C Aug 11 '14 at 8:03

## 1 Answer

For an actual graph where you plan to communicate something useful about your data you don't (or shouldn't) want it to look like this. But simply as an exercise the following, while a bit kludgy, is a first step in the right direction:

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{shadows,fadings}
\tikzset{pics/.cd,
cylinder/.style 2 args={%
code={
\colorlet{cylinder color}{#2}
\edef\ch{#1}
\foreach \i in {-1,1}{
\begin{scope}[yscale=\i]
\ifnum \i=1
\path [circular glow={fill=black, opacity=0.25}]
ellipse [x radius=1, y radius=1/2];
\else
\def\ch{2}
\fi
\begin{scope}
\clip [preaction={left color=cylinder color, right color=cylinder color!25!black}] (1,0) arc (360:180:1 and 1/2) -- ++(0,\ch) arc (180:0:1 and 1/3) -- cycle;
\fill [white, opacity=0.25, path fading=east]
(0.75,-1) rectangle (1,\ch+1);
\fill [white, opacity=0.25, path fading=west]
(0.75,-1) rectangle (0.25,\ch+1);
\fill [white, opacity=0.25, path fading=west]
(-0.5,-1) rectangle (-0.875,\ch+1);
\fill [white, opacity=0.25, path fading=east]
(-0.5,-1) rectangle (-0.125,\ch+1);
\end{scope}
\ifnum\i<0\relax
\fill [white, opacity=0.25]
(-1,0) rectangle (1,\ch+1/2);
\fill [white, path fading=north]
(-1,0) rectangle (1,\ch+1/2);
\else
\shade [left color=cylinder color, right color=cylinder color!25!black,
postaction={fill=white,opacity=0.25, path fading=north}] (0,\ch) ellipse [x radius=1, y radius=1/3];
\fi
\end{scope}
}}}}
\begin{document}
\begin{tikzpicture}
\foreach \y/\c [count=\i from 1]
in {6/blue,5/cyan,4/green,3/yellow,2/orange,1/red}
\path (\i*60-15:5 and 1) pic {cylinder={\y}{\c}};
\end{tikzpicture}
\end{document}