1

Is there a way, to shift the texts in the lower left corners;
with other words: how to hack the default of the package pgf-pie.sty?

Note that I use fictional percentual values.

gf

\documentclass[border=5pt, tikz]{standalone}
\usepackage{pgf-pie}

\begin{document}
\begin{tikzpicture}[xscale = 1.75, 
 font=\sffamily,
mystyle/.style={draw=white, very thick, text=white, font=\sffamily\bfseries},
]
\pie[square,  
style={mystyle},
color={yellow!80!orange, gray, blue!40, orange}, 
%text=inside,
text=legend, 
]{68/A, 22/B, 5/C, 5/D}
\end {tikzpicture}

\end{document}
3

1 Answer 1

1

This is a comment, not an answer: using plain tikz for easily fine-turning and flexibility. IMHO it wastes time to hack not-so-flexible package.

I give below some alternatives: circle chart, rectangle chart, and strip chart (so simple!). Some easy calculations are needed.

Circle chart enter image description here

\documentclass[border=5mm,tikz]{standalone}
\begin{document}
\begin{tikzpicture}[line join=round,font=\sffamily]
\def\r{2}
\pgfmathsetmacro{\a}{5/100*360} % a=18
\pgfmathsetmacro{\b}{22/100*360}
\pgfmathsetmacro{\c}{68/100*360}
\fill[yellow!80!orange,draw=white] (0,0) circle(\r);
\fill[orange,draw=white] (0,0)--+(0:\r) arc(0:-\a:\r)--cycle;
\fill[blue!40,draw=white] (0,0)--+(0:\r) arc(0:\a:\r)--cycle;
\fill[gray,draw=white] (0,0)--+(-\a:\r) arc(-\a:-\a-\b:\r)--cycle;
\path[white]
(\a/2:.8*\r) node[scale=.6]{$5\%$}
(-\a/2:.8*\r) node[scale=.6]{$5\%$}
(-\a-\b/2:.6*\r) node[scale=.8]{$22\%$}
(\a+\c/2:.5*\r) node{$68\%$};
\def\s{.25} \def\t{.15}
\path[sq/.pic={\fill (-\t,-\t) rectangle(\t,\t);}] 
(1.5*\r,3*\s) pic[yellow!80!orange]{sq} node[right=1.5mm]{A}
(1.5*\r,\s) pic[gray]{sq} node[right=1.5mm]{B}
(1.5*\r,-\s) pic[blue!40]{sq} node[right=1.5mm]{C}
(1.5*\r,-3*\s) pic[orange]{sq} node[right=1.5mm]{D};
\end{tikzpicture}
\end{document}

Rectangle chart In case you are stick with rectangle chart, you can do it similarly.

enter image description here

\begin{tikzpicture}[font=\sffamily]
\fill[blue!40,draw=white] (0,0) rectangle +(1,1) ;
\fill[orange,draw=white] (1,0) rectangle +(1,1);
\pgfmathsetmacro{\b}{11/5}
\fill[gray,draw=white] (0,0) rectangle +(2,-\b);
\pgfmathsetmacro{\c}{17/4}
\fill[yellow!80!orange,draw=white] (0,1) rectangle (-\c,-\b);

\path[white] 
(0,0) node[above right,scale=.6]{$5\%$}
(1,0) node[above right,scale=.6]{$5\%$}
(0,-\b) node[above right,scale=.8]{$22\%$}
(-\c,-\b) node[above right]{$68\%$};

\path[sq/.pic={\fill (-\t,-\t) rectangle(\t,\t);}] 
(current bounding box.east)++(0:1)
+(90:3*\s) pic[yellow!80!orange]{sq} node[right=1.5mm]{A}
+(90:\s) pic[gray]{sq} node[right=1.5mm]{B}
+(-90:\s) pic[blue!40]{sq} node[right=1.5mm]{C}
+(-90:3*\s) pic[orange]{sq} node[right=1.5mm]{D};
\end{tikzpicture}

Strip chart This is simplest one.

enter image description here

\begin{tikzpicture}[font=\sffamily,line width=10mm]
\draw[yellow!80!orange] (0,0) rectangle ++(0:6.8) coordinate (A);
\draw[gray] (A) rectangle ++(0:2.2) coordinate (B);
\draw[blue!40] (B) rectangle ++(0:.5) coordinate (C);
\draw[orange] (C) rectangle ++(0:.5) coordinate (D);

\path[every node/.style={midway}] (0,0)
--(A) node[above]{$68\%$} node[below]{A}
--(B) node[above]{$22\%$} node[below]{B}
--(C) node[above]{$5\%$}  node[below]{C}
--(D) node[above]{$5\%$}  node[below]{D};
\end{tikzpicture}
2
  • Nice picture, but I fear this is not my question.
    – cis
    Jan 23, 2020 at 19:50
  • @cis: see my update comment ^^
    – Black Mild
    Jan 23, 2020 at 19:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .