5

I have a following code which plots a pgf bar plot for me. I am able to add shadow to one of the bar plot. However, the other plot which has a broken y bars, I am unable to add the shadow, because pdflatex throws dimension too large error. I don't know how to resolve this.

Also could anyone give me a tip on how to increase spacing between two bars. ybar=2pt would change the distance between two bars in every solution or point. However, I don't want to change this distance. Sorry, if I am not clear in the explanation. I have added the picture below. The arrow shows the distance I would like to increase.

enter image description here

Thanks !

\documentclass[tikz,border=5pt]{standalone}

\usepackage[T1]{fontenc}
\usepackage[oldstylenums]{kpfonts}
\usepackage{microtype}
\usepackage{pifont}
\usepackage{amssymb}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{pgf}
\usepackage{pgfplots}

\pgfplotsset{compat=1.8}

\usepackage{tikz}
\usetikzlibrary{arrows,automata,calc,shapes, positioning,shadows,shadows.blur,shapes.geometric}

\begin{document}
\definecolor{col1}{RGB}{204, 204, 154}
\definecolor{col2}{RGB}{136, 136, 136}
\pgfplotsset{compat=newest}
\pgfplotsset{major grid style={gray!50}}

\begin{tikzpicture}
    \begin{axis}[
        every axis plot post/.style={/pgf/number format/fixed},
            bar width=4pt,
            xtick=data,
            xticklabels = {Jpeg Dec., BeamFormer, Insertion Sort, Merge Sort, Radix Sort, Dct1, Dct2, Dct3, Dct4, Dct5, Dct6, Dct7, Dct8, DctCoarse, DctFine, Comp. count, Matrix Mult., Fft},
        x tick label style={rotate=45, anchor=north east, inner sep=0mm,font=\tiny,major tick length=0pt},
        y tick label style={font=\tiny,major tick length=0pt},
        xticklabel shift={.1cm},
        ybar=1pt,
        xmin=-1,
        xmax=18,
        ymin=0,
        ymax=100,
        ymajorgrids,
        restrict y to domain*=0:105,
        visualization depends on=rawy\as\rawy,
        after end axis/.code={ % Draw line indicating break
                    \draw [ultra thick, white, decoration={snake, amplitude=1pt}, decorate] (rel axis cs:0,1.02) -- (rel axis cs:1,1.02);
                            },
        every node near coord/.style={font=\tiny,rotate=90,yshift=-0.1cm,xshift=0.1cm},
        axis lines*=none,
        axis line style={ultra thin,white},
        clip=false,
        legend columns=2,
        legend style={
        ultra thin,
    append after command={
    \pgfextra{
      \draw[draw=none,
      drop shadow={fill=black, opacity=0.5, shadow xshift=2pt, shadow yshift=-2pt}]
        (\tikzlastnode.south west)rectangle(\tikzlastnode.north east);
      }   
      },  
  }]  
    \addplot[draw=none,fill=col1, draw opacity=0,area legend,nodes near coords={\pgfmathprintnumber{\rawy}}] table[x=Number,y=Pareto] {errorPlot.csv};
    \addplot[draw=none,fill=col2, draw opacity=0,area legend,blur shadow={shadow yshift=0pt, shadow xshift=1pt}] table[x=Number,y=Max-Latency-Error] {errorPlot.csv};
     \legend{\#Solutions, \%error}
\end{axis}
\end{tikzpicture}
\end{document}

errorPlot.csv file is as -

Number  Pareto  Max-Latency-Error
0   25  8
1   155 15
2   7   15
3   37  16
4   6   15
5   4   3
6   8   8
7   4   10
8   8   7
9   8   14
10  24  19
11  7   12
12  10  11
13  3   6
14  6   22
15  4   27
16  8   14
17  8   8

1 Answer 1

1

Solved the bar spacing, the nodes near coords are better and fully placed, and replace the blur shadow by drop shadow.

enter image description here

\documentclass[tikz,border=5pt]{standalone}

\usepackage[T1]{fontenc}
\usepackage[oldstylenums]{kpfonts}
\usepackage{microtype}
\usepackage{pifont}
\usepackage{amssymb}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{pgf}
\usepackage{pgfplots}

\pgfplotsset{compat=1.8}

\usepackage{tikz}
\usetikzlibrary{arrows,automata,calc,shapes, positioning,shadows,shadows.blur,shapes.geometric}

\begin{document}
\definecolor{col1}{RGB}{204, 204, 154}
\definecolor{col2}{RGB}{136, 136, 136}
\pgfplotsset{compat=newest}
\pgfplotsset{major grid style={gray!50}}


\begin{tikzpicture}
    \begin{axis}[
    width=10cm,nodes near coords,
    nodes near coords align={vertical},
        every axis plot post/.style={/pgf/number format/fixed},
            bar width=4pt,
            xtick=data,
            xticklabels = {Jpeg Dec., BeamFormer, Insertion Sort, Merge Sort, Radix Sort, Dct1, Dct2, Dct3, Dct4, Dct5, Dct6, Dct7, Dct8, DctCoarse, DctFine, Comp. count, Matrix Mult., Fft},
        x tick label style={rotate=45, anchor=north east, inner sep=0mm,font=\tiny,major tick length=0pt},
        y tick label style={font=\tiny,major tick length=0pt},
        xticklabel shift={.1cm},
        ybar=1pt,
        xmin=-1,
        xmax=18,
        ymin=0,
        ymax=100,
        ymajorgrids,
        restrict y to domain*=0:105,
        visualization depends on=rawy\as\rawy,
        after end axis/.code={ % Draw line indicating break
            \draw [ultra thick, white, decoration={snake, amplitude=1pt}, decorate] (rel axis cs:0,1.02) -- (rel axis cs:1,1.02);},
        axis lines*=none,
        axis line style={ultra thin,white},
        clip=false,
        legend columns=2,
        legend style={
        ultra thin,
    append after command={
    \pgfextra{
      \draw[draw=none,
      drop shadow={fill=black, opacity=0.5, shadow xshift=2pt, shadow yshift=-2pt}]
        (\tikzlastnode.south west)rectangle(\tikzlastnode.north east);
      }   
      },  
  }]  

    \addplot[draw=none,fill=col1, draw opacity=0,area legend,
    every node near coord/.style={font=\tiny,right,xshift=-2.5pt,rotate=90},
    drop shadow={shadow yshift=1pt, shadow xshift=1pt},
    nodes near coords={\pgfmathprintnumber{\rawy}}
    ] table[x=Number,y=Pareto] {errorPlot.csv};

    \addplot[draw=none,fill=col2, draw opacity=0,area legend,
    every node near coord/.style={font=\tiny,right,xshift=2.5pt,rotate=90},
   drop shadow={shadow yshift=1pt, shadow xshift=1pt}
   ]
     table[x=Number,y=Max-Latency-Error] {errorPlot.csv};

      \legend{\#Solutions, \%error};
\end{axis}
\end{tikzpicture}
\end{document}
4
  • @Raj Is there some points I didn't understand ?
    – Tarass
    Apr 28, 2014 at 9:35
  • this is just perfect ! thanks ! the only thing is that blur shadow looks better than drop shadow. but its fine. :) Apr 28, 2014 at 12:52
  • I don't understand why blur doesn't work ...
    – Tarass
    Apr 28, 2014 at 13:08
  • the only thing i know is that with blur shadow, somehow the range setting is exceeded. it must be related to how the shadow is calculated, but i don't really know the internals. Apr 28, 2014 at 13:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .