I'm avoiding pie charts and I would like to convert this pie chart to a stacked horizontal bar chart:
The x ticks would be percentage (how to include the sign?) and the absolute numbers (where percentage is derived from) inside the bars. The legend can be either inside the bars or below the chart but I think the four bars should have different colors.
Here is what i got so far:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{testbar/.style={
nodes near coords xbar stacked configuration/.style={},
xbar stacked,
width=.8\textwidth,
xmajorgrids = true,
xmin=0,xmax=100,
ytick = data, yticklabels = {Sex,Handedness},
tick align = outside, xtick pos = left,
bar width=6mm, y=8mm,
nodes near coords,
nodes near coords align={horizontal},
}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[testbar]
\addplot coordinates{(58.8,1) (82.4,0)};
\addplot coordinates{(41.2,1) (17.6,0)};
\end{axis}
\end{tikzpicture}
\end{document}
I guess this should be easy but I am a beginner at tikz/pgfplots.