I have some code that plots a horizontal barchart. What I would like to do is put a boxplot or confidence interval above my horizontal axis which is on top of the chart. GNU R (see R In Action, Robert Kabacoff) allows boxplots along/out-side the horizontal/vertical axis which gives a nice look and much information at a glance.

In a similar manner, I was trying to add a boxplot or horizontal error bars above the x axis labels. Since the boxplot plots quartiles, error bars/confidence interval with the min/max about the mean may be more meaningful for what I'm showing. How do I get something like that? Is there some clipping going on, as my axis shift up seems to ignore larger shift values. Also, I can't get the vertical red line to extend above the x axis. My thought was to plot a thick red line of +/- n SDEV and thin error bars of min/max above the x axis and a boxplot on the bottom of the chart. With that I would like to label the \mu and +/- n\sigma points if possible.

I commented out the error bar addplot below. Another thought is how can I get PGFPLOTS to calculate the mean/sdev. If boxplot can calculate the quartiles, is there some mechanism to pull the data column Miles from the inline table?

I started this project keeping Tufte Principles in mind, but I keep adding more ink items. I hope to merge some other data into this type of chart. I really appreciate any help with this problem. Regards, Dave

\pgfplotsset{width=.95\textwidth, compat=newest} 

    discard if/.style 2 args={
        x filter/.code={
    discard if not/.style 2 args={
        x filter/.code={

\pgfkeys{/pgfplots/x axis shift down/.style={
    x axis line style={yshift=-#1},
    xtick style={yshift=-#1},
    xticklabel shift={#1}}}
\pgfkeys{/pgfplots/y axis shift left/.style={
    y axis line style={xshift=-#1},
    ytick style={xshift=-#1},
    yticklabel shift={#1}}}

Miles,   Bike,    rdate 
12.5,    Yel-11,  {$\stackrel{\hbox{Yel-11}}   {\hbox{\tiny 03/30/14}}$}
16.5,    Fuji,    {$\stackrel{\hbox{Fuji}}     {\hbox{\tiny 04/23/14}}$}
21.0,    8000SHX, {$\stackrel{\hbox{8000SHX}}  {\hbox{\tiny 05/18/14}}$}
24.2,    Yel-11,  {$\stackrel{\hbox{Yel-11}}   {\hbox{\tiny 05/24/14}}$}


\pgfplotsset{every axis/.append style={semithick,tick style={major tick
\fbox{ \begin{tikzpicture}
%/pgf/number format/.cd,1000 sep={},
xbar,/pgf/bar shift=0pt,
% title style={yshift=1cm},
% title={\centering More Customization: ``colorbar top''},
title={\centering label 2014},
title style={yshift=1cm, text width=8cm,font=\rmfamily\itshape\Large},
xmin=0, xmax=50, xticklabel pos=upper, tick align=outside,
xticklabel style={major tick length=20pt, color=black,tickwidth={10pt}},
axis x line*=top, %tickwidth={2pt},
axis y line*=left, y axis line style={opacity=0},
xmajorgrids, major grid style=white, axis on top,
xtick={0,10,15,20,25,30,35,40,50}, %,100,150,200,250},
separate axis lines, x axis shift up=35pt, y axis shift left=10pt,
%xtick=\empty, %xlabel= {},
%enlarge x limits={value=0.1, upper},
enlarge y limits=0.25,
%ytick={0,...,\pgfmathresult}, %\pgfplotsretval},
y dir=reverse,
y tick label style={align=right, major tick length=5pt},
yticklabels from table={data.csv}{[index]2},
nodes near coords, nodes near coords align=horizontal,
%point meta=explicit symbolic

\addplot [draw,fill=blue, discard if not={Bike}{Fuji}] 
        table [y expr=\coordindex, x index=0, col sep=comma]{data.csv};

% \addplot [draw,fill=blue!60!white, discard if not={Bike}{Yfoil}] 
%         table [y expr=\coordindex, x index=0, col sep=comma]{data.csv};

\addplot [draw,fill=yellow,  discard if not={Bike}{Yel-11}] 
        table [ y expr=\coordindex, x index=0,col sep=comma]{data.csv};

% \addplot [draw,fill=red,     discard if not={Bike}{Y-22}] 
%         table [ y expr=\coordindex, x index=0,col sep=comma]{data.csv};

\addplot [draw,fill=gray,    discard if not={Bike}{8000SHX}] 
        table [ y expr=\coordindex, x index=0,col sep=comma]{data.csv};

\draw [red,dotted,thick] (axis cs:18.6,-1) -- (axis cs:18.6,29)
       node[anchor=west,on top] at (axis cs:19.0,0.5)
\draw  node[anchor=center,on top] at (axis cs:40.0,3) {label};

%\addplot[error bars/.cd, x dir=both, x fixed=5.12,] coordinates{ (18.6,-1)};

\end{tikzpicture}  }%fbox

closed as unclear what you're asking by Stefan Pinnow, ebosi, CarLaTeX, Moriambar, Zarko May 18 '17 at 21:37

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    You've forgotten to add the definition of x axis shift up and on top. And yes, stuff outside the axis limits are clipped by default, try adding clip=false to the axis options. – Torbjørn T. May 26 '14 at 7:35
  • Did the tricks of Torbørn T. help to solve your question so we can close it as being solved or do you need further assistance? – Stefan Pinnow Nov 8 '16 at 19:35