We have the ability to avoid math mode in PGF using something like this: \pgfmathprintnumber[assume math mode=true].
Then I can make really good-looking material as shown here:
Note that the tick numbers are in math mode. I'd like to avoid this. Using x tick label style={assume math mode=true} fails.
Code
\documentclass{article}
\usepackage{fontspec}% xelatex
\renewcommand\familydefault{\sfdefault}% to emphasize font change between math mode and reg mode
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{fancyvrb}% for VerbatimOut to write bar chart data to tmp file
\pgfplotsset{horizontalbarchartstyle/.style={
% symbolic y coords=,% set dict of expected textual y coordinates, we avoid this dup of data by using "yticklabels from table" and "ytick=data"
axis lines*=left,
y=1cm,% vertical spacing (define the length of a unit in the y direction )
xbar,
bar width=5mm,% bar thickness
y axis line style = { opacity = 0 },
x axis line style = { black!35 },
width=.7\textwidth,
% xmajorgrids,
% xminorgrids,
xlabel={}, % optional label below x axis but useless in global style
xmin=0,
xmax=100,
xtick={0,100,...,100},
% minor xtick={12.5,37.5,...,100},
point meta={x},
nodes near coords={\color{blue!85!black}\pgfmathprintnumber[assume math mode=true]{\pgfplotspointmeta}\%},% puts text (set in "point meta" key) near coordinates.
every node near coord/.style={font=\bfseries},
nodes near coords align={horizontal},% alignment of "nodes near coords"
enlarge y limits={abs=10mm},% add space above and below bars
yticklabels from table={\datatable}{1}, % necessary for pgfplotstableread data
ytick=data,
x tick label style={font=\sffamily\footnotesize,black!35},
% x tick style={opacity=0},
y tick style={opacity=0},
y tick label style={color=orange},
legend style={font=\footnotesize},
label style={font=\footnotesize},
minor grid style={dotted,green!50!black},
major grid style={dashed,orange},
},
}
\tikzset{addplot-color1/.style={draw=none,fill=blue!85!black}}% bar format
\newenvironment{horizontalbarchart}
{\VerbatimOut{\jobname-horizontalbarchart.tmp}}%begin
{\endVerbatimOut\par
% Inject BODY into pgfplotstableread
\pgfplotstableread[col sep=comma, header=false]{\jobname-horizontalbarchart.tmp}{\datatable}
% Use \datatable for plot data
\begin{tikzpicture}
\begin{axis}[horizontalbarchartstyle]
\addplot [addplot-color1] table [col sep=comma, y expr=\coordindex, x=0] {\datatable};
\end{axis}
\end{tikzpicture}\par
}%
\begin{document}
\begin{horizontalbarchart}
40,Apples
10,Strawberries
20,Rasberries
\end{horizontalbarchart}
\end{document}
