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.

In our company we would like to run the client reportings in LaTeX, which works quite well, but we are struggeling with the design requirements for plots - we use pgfplots. Our aim is to get those fancy "kind of reflecting" plots, which also could use some shadow, so it looks a bit three-dimensional.

The only shadow we can get is this drop shadow, but it should look like the glowing shadow in the TikZ/PGF reference (v2.1 p.418), which seems only available for circles (at least for me). For the reflection I tried fadings, but this leeds to problems with the shadow. Also the fading does not work equal for all bars, but depends on their heights.

Last points are the round corners, which work, but for the top corners and the bottom corners (intererstingly not for the shadow). This also looks strange and it would be prefered to only get round top corners.

Below I attached a small sample with our current status and I would be glad for suggestions.

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{shadows}

\begin{document}

\tikzfading[name=fade down,
    top color=transparent!30,
    bottom color=transparent!0]

\begin{tikzpicture}
    \begin{axis}[axis x line*=bottom,
            axis y line*=left, drop shadow] 
    \addplot[ybar, blue, fill,path fading=fade down, rounded corners=2pt]
    coordinates{(1,2.9) (2,1.7) (3,4.2) (4,5.1) (5,4) (6,2.2)};
\end{axis}
\end{tikzpicture}

\end{document}
share|improve this question
    
I'm pretty sure you're not going to like it, but set yourself positively apart by not participating in this "flashy plots" nonsense. Your clients are probably interested the information you have, not all the capabilities of your plotting software. I sure would appreciate a precise, uncluttered, plain but well made plot over fake 3D, reflections and shadows. –  Psirus Feb 22 '12 at 6:57
    
I would not disagree with you at all, but first of all it's not only my decision and additionally I'm very interested in getting to know how to change the look of bars individually, which I'm currently really struggeling with. –  Jack Schwager Feb 22 '12 at 7:43
    
Try using clip=false inside of the axis - this will show the rounded corners for the shadows as well. I think it is unsupported to get only rounded corners on top of the bars. –  Christian Feuersänger Feb 25 '12 at 11:43

1 Answer 1

There are many hacks that can be applied but I think this is innocent enough to be considered as a solution.

For the shadows, one can use the pgf-blur package(or library for TikZ with a .dtx file) developed by Martin Giese. See Reuse of soft path in fading declaration? Transformation of fadings? So combining the nice shadows with the plot shift such that the rounded rectangles disappear, it looks like "3D". The reason why the shadows don't have the problem is precisely why this hack works they are clipped by the axis.

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{shadows.blur}

\begin{document}

\tikzfading[name=fade down,
    top color=transparent!30,
    bottom color=transparent!0]

\begin{tikzpicture}
    \begin{axis}[axis x line*=bottom,
            axis y line*=left, blur shadow] 
    \addplot[yshift=-2pt,ybar, blue, fill,path fading=fade down, rounded corners=2pt]
    coordinates{(1,2.9) (2,1.7) (3,4.2) (4,5.1) (5,4) (6,2.2)};
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
This solution to shadows doesn't seem to work with stacked bar charts. It adds the shadows on top of the later bars. Any workaround for this? –  Trevor Aug 17 '12 at 22:10
    
@Trevor Not with some quick fix since the stacked bars are added on top of each other,but they have to be put in a big rectangle for the roubnd corners and the shadow. Or let say I don't see it right away. –  percusse Aug 17 '12 at 22:14

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.