I have two charts, one is drawn with pgfplots
, the other with pgf-pie
. I want put these two chart in align horizontally, so one is on the left and the other is on the right. I have read Aligning using flushleft and flushright, but it seems this minipage
trick does not work in my case.
This is an example. I expected the two charts stand side-by-side, but they are not. About the width of the minipage
, I tried many values. Maybe I don't understand it correctly.
\begin{minipage}{0.5 \linewidth}
\begin{flushleft}
\begin{tikzpicture}
\begin{axis}[
title=\# of players in a class,
ybar,
%enlargelimits=0.15,
legend style={at={(0.5,-0.2)},
anchor=north,legend columns=-1},
ylabel={Population},
symbolic x coords={Warrior,Wizard,Archer},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
x tick label style={rotate=45,anchor=east},
]
\addplot coordinates {(Warrior,100) (Wizard,100) (Archer,200)};
\end{axis}
\end{tikzpicture}
\end{flushleft}
\end{minipage}
\begin{minipage}{0.5 \linewidth}
\begin{flushright}
Ratio of players in a class
\begin{tikzpicture}
\pie{ 25/ \textsc{Warrior} , 25/ \textsc{Wizard} , 50/ \textsc{Archer} }
\end{tikzpicture}
\end{flushright}
\end{minipage}
Best Answer
The
minipage
trick still does work, but0.5\linewidth
.To fix Problem 1: Remove the newlines and add comments at ends of lines to suppress spurious spaces. You also need to add
\hfill
between theminipages
as in the linked solution.To fix Problem 2: You can adjust the
width
key in theaxis
environment to change the size of the plot. You can also use thescale
option to thetikzpicture
to adjust the size of the pie chart.You can remove the
\fbox
es for your own usage; I've just used them here to show the size of theminipage
s.