You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With pgf-pie, you can only draw, most of the time, one pie with
legends, alone in a tikzpicture. Most of the time, if you draw two
pies with legends, the location of the legend is wrong for the second
pie (unless you draw them aligned horizontally, and from left to
right).
With one pie the location of the legend is correct:
% legend\iflegend\coordinate[xshift=0.8cm,
yshift=(\value{pgfpie@sliceLength}*0.5+1)*0.5cm] (legendpos) at
(current bounding box.east);
\begin{scope}[node distance=0.5cm]
\foreach\p/\t [count=\i from 0] in {#2}
{
\pgfpie@findColor{\i}
\node[draw, fill=\thecolor, \pgfpie@style, below of=legendpos, label=0:\t] (legendpos) {};
}
\end{scope}
\fi
The location of the legend is provided by (current bounding box.east) so if any other
drawing moves the right boundary of the current bounding box, the location of the legend
is then wrong.
A solution would be to scope the drawing of the pie and save the boundary of the bounding
box of the scope.
\begin{scope}[local bounding box=scope bounding box]
% ... draw the pie ...\end{scope}
Now when you want to deduce the location of the legend, you can rely
on (scope bounding box): instead of
yshift=(\value{pgfpie@sliceLength}*0.5+1)*0.5cm] (legendpos) at
(current bounding box.east);
you can use:
yshift=(\value{pgfpie@sliceLength}*0.5+1)*0.5cm] (legendpos) at
(scope bounding box.east);
So the location of the legend will be always be attached to the
location of the pie.
Dear all,
With pgf-pie, you can only draw, most of the time, one pie with
legends, alone in a tikzpicture. Most of the time, if you draw two
pies with legends, the location of the legend is wrong for the second
pie (unless you draw them aligned horizontally, and from left to
right).
With one pie the location of the legend is correct:
\pie[text=legend, pos={-5,0}]{10/First, 20/Second, 30/Third, 40/Fourth};
but with two (or more) pies:
or
the location is wrong unless you draw them aligned horizontally, and from left to right:
Equally, if you draw other elements before drawing your pie, the location of the legend is also wrong:
The reason is the last lines of pfg-pie.sty:
The location of the legend is provided by (current bounding box.east) so if any other
drawing moves the right boundary of the current bounding box, the location of the legend
is then wrong.
A solution would be to scope the drawing of the pie and save the boundary of the bounding
box of the scope.
Now when you want to deduce the location of the legend, you can rely
on (scope bounding box): instead of
yshift=(\value{pgfpie@sliceLength}*0.5+1)*0.5cm] (legendpos) at (current bounding box.east);
you can use:
yshift=(\value{pgfpie@sliceLength}*0.5+1)*0.5cm] (legendpos) at (scope bounding box.east);
So the location of the legend will be always be attached to the
location of the pie.
Thank you,
J.F.
Example:
The text was updated successfully, but these errors were encountered: