I am creating a stacked barchart with the following code.
However, I have some problems.
- How do I set the width, of the whole thing? width= does not do it …
- How can I get thicker bars?
- How can I get them narrower?
Code:
\begin{figure}
\begin{tikzpicture}
\begin{axis}[xbar stacked,
%legend cell align=left,
legend style={legend columns=4,at={(0,-0.2)},anchor=north west,draw=none},
yticklabels={Chromium 16, Firefox 9, Internet Explorer 9, Internet Explorer 8},
xmin=0,
]
%Chrome Firefox IE 9 IE 8
\addplot coordinates
% Transfer
{(0.38,0) (0.07,1) (0.12,2) (1,3)};
\addplot coordinates
% Database
{(6.99,0) (6.99,1) (6.98,2) (6.95,3)};
\addplot coordinates
% Transfer
{(0.04,0) (0.04,1) (0.08,2) (0.23,3)};
\addplot coordinates
% Rendering
{(1.8,0) (2.38,1) (6,2) (14.66,3)};
\legend{Transfer,Database,Transfer,Rendering}
\end{axis}
\end{tikzpicture}
\caption{Performance}
\label{fig:perf}
\end{figure}
Best Answer
You can get thicker bars using
You can set the width of the plot using
I generally specify my
width
in terms of\textwidth
so that it scales appropriately if the dimensions of the page change, but there's nothing to stop you from using a static measurement (such as8cm
).In the code below, I also specified your
ytick={0,1,2,3}
so that theyticklabels
behaved correctly.