Tell me more ×
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 make two graphs using TiKz pgfplots or otherwise using this table below. But get the error

! Package pgfplots Error: Sorry, the input coordinate `Bloodstream Infection (B SI' has not been defined with 'symbolic y coords={Bloodstream Infection (BSI),S urgical site infections (SSI),Ventilator-associated pneumonia (VAP),Urinary tra ct infection (UTI),Others}... Maybe it has been misspelled?.

Have I not correctly defined the names in y coords?

**Type of infection Mean cost   Stdev   St dev Min  Stdev Max   %**
Bloodstream Infection (BSI) 36441   37078   2883    207256  14
Surgical site infections (SSI)  25546   39875   1783    134602  17
Ventilator-associated pneumonia (VAP)   9969    2920    7904    12034   14
Urinary tract infection (UTI)   1006    503 650 1361    33
Others  1000    1000    800 5000    22

Type of infection vs Cost Type of infection vs %

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

\begin{document}

 \begin{tikzpicture}
\begin{axis}[ 
xbar, xmin=0,
xlabel={Percentage \%},
symbolic y coords={{Bloodstream Infection (BSI)},{Surgical site infections (SSI)},{Ventilator-associated pneumonia (VAP)},{Urinary tract infection (UTI)},{Others}},
ytick=data,
nodes near coords, nodes near coords align={horizontal},
ytick=data,
]
\addplot coordinates {(14,{Bloodstream Infection (BSI)}) (17,{Surgical site infections (SSI)}) (14,{Ventilator-associated pneumonia (VAP)}) (33,{Urinary tract infection (UTI)})(22, {Others})};
\end{axis}
\end{tikzpicture} %width=6cm,height=7.59cm

\end{document}
share|improve this question
2  
same problem. The closing parenthesis of (BSI fools pgfplots that coordinate is finished. Braces around them are needed – percusse Mar 19 at 18:29
Ahh thank you! I'm having a lot of trouble with braces today! What would the commands be to get the same colours do you know? – HCAI Mar 19 at 18:31
Updated code but continues to have problems – HCAI Mar 19 at 18:40
1  
Remove the space in (22, {Others}). You only need braces if you want to protect spaces, commas etc. For single word you don't need them. Instead of this you can use numbers and then change the y tick labels. – percusse Mar 19 at 18:43
I understand, thank you. The first graph looks like it will take me all evening. – HCAI Mar 19 at 19:11

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.