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.

I'd like to display the yticklabel as Thousands \euro or \pounds, but doesn't quite looks right, what do you think?

        \documentclass{article}
    \usepackage{tikz} 
    \usepackage{pgfplots}
    \pgfplotsset{compat=newest}
    \usetikzlibrary{pgfplots.units}
    \usepgfplotslibrary{units}
    \begin{document}

 \begin{tikzpicture}
\begin{axis}[
title = {Optimalization based upon co-occurences},
xbar,
width=10cm,
change y base,
y SI prefix=kilo,y unit=Thousands,
xtick={1,...,5},
yticklabel={\pgfmathprintnumber{\tick}\pounds{}},
xticklabels={{Bloodstream infections (BSI)},{Surgical site infections (SSI)},{Ventilator-associated pneumonia (VAP)},{Urinary tract infections (UTI)},{Others}},
    grid=major,
 x tick label style={rotate=45,anchor=east},   ]

\addplot[fill=blue,draw=black,ybar,error bars/.cd,y dir=both,y explicit] 
coordinates
{
(1, 36441   )+-(    207256  ,   2883    )
(2, 25546   )+-(    134602  ,   1783    )
(3, 9969    )+-(    12034   ,   7904    )
(4, 1006    )+-(    1361    ,   650 )
(5, 1000    )+-(    5000    ,   800 )

};
\end{axis}
\end{tikzpicture}
    \end{document}

Would be nice if it looked like the graph below. Any suggestions? I see a siunitx library but no specific example around. Surely there is one... enter image description here

share|improve this question

1 Answer 1

up vote 4 down vote accepted

enter image description here

it needs thousands adding somewhere...

\documentclass{article}
\usepackage{tikz} 
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{units}

\usepackage[space-before-unit,range-units = repeat]{siunitx}
\begin{document}

\begin{tikzpicture}
\begin{axis}[
title = {Optimalization based upon co-occurences},
xbar,
width=10cm,
xtick={1,...,5},
xticklabels={{Bloodstream infections (BSI)},{Surgical site infections (SSI)},{Ventilator-associated pneumonia (VAP)},{Urinary tract infections (UTI)},{Others}},
    grid=major,
 x tick label style={rotate=45,anchor=east}, 
yticklabel={\pgfmathparse{(int(\tick))}\pounds{}\pgfmathresult},
ytick scale label code/.code={},
scaled y ticks=base 10:-3,
  ]

\addplot[fill=blue,draw=black,ybar,error bars/.cd,y dir=both,y explicit] 
coordinates
{
(1, 36441   )+-(    207256  ,   2883    )
(2, 25546   )+-(    134602  ,   1783    )
(3, 9969    )+-(    12034   ,   7904    )
(4, 1006    )+-(    1361    ,   650 )
(5, 1000    )+-(    5000    ,   800 )

};
\end{axis}
\end{tikzpicture}
\end{document}
share|improve this answer
    
Very nice! thanks! y unit=Thousands, This just looks about passable, but it has []around it... Incidentally the error bars don't quite look right. They are supposed to be assymetric. Do the two right most columns of data not represent this? –  HCAI Mar 19 '13 at 22:23
    
@user1134241 I have no idea about tikz or pgf, I just stole some plausible looking keys from random searches:-) –  David Carlisle Mar 19 '13 at 22:25
    
@user1134241 I'm not sure but as far as I know the asymmetric error bars are not supported off-the-shelf. It's kind of understandable since as long as you are inside the region it doesn't matter where the bar ends. If you have an expected value and a nonuniform distribution then this might not be a good choice to display that information. –  percusse Mar 19 '13 at 22:28
    
@percusse what im actually trying to display the range of the data by using errorbars. Would you suggest a different way to display this? –  HCAI Mar 19 '13 at 23:24

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.