我想将其显示yticklabel
为千位\euro
或\pounds
,但看起来不太正确,您觉得呢?
\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}
如果它看起来像下面的图表,那就太好了。有什么建议吗?我看到了一个 siunitx 库,但没有具体的例子。肯定有一个……
答案1
它需要thousands
在某处添加...
\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}