1

How do I put a title on the following pie chart? I tried using \stackon.

\documentclass[10pt]{amsart}
\usepackage{mathtools,systeme,array}

\usepackage{tikz}

\usepackage{adjustbox}
\usepackage{mathtools}

\usepackage{array}
\usepackage{makecell}
\usepackage{stackengine}\setstackEOL{\cr} %EOL is abbreviation for "end of line."


\begin{document}


%\setlength\extrarowheight{2pt}
%\stackon{%


\begin{tikzpicture}[every node/.style={align=center}, pin distance=5mm]

\coordinate (O) at (0,0);
\draw (O) circle (3);
\draw (O) -- (0:3);
\draw (O) -- (90:3);
\draw (O) -- (216:3);
\draw (O) -- (234:3);
\draw (O) -- (288:3);

\path (O) -- node{Food \\ 25\%} (45:3);
\path (O) -- node{Rent and \\ Utilities \\ 35\%} (153:3);
\path (O) -- node[pin=225:Clothing \\ 5\%] {} (225:5);
\path (O) -- node{Other \\ 5\%} (261:3);
\path (O) -- node{Car \\ 20\%} (324:3);
\end{tikzpicture}

%}{\bfseries\Longstack{David's Monthly Expenses}}


\end{document}
user74973
  • 4,071
  • What does this have to do with [tag:tables]? –  May 27 '15 at 23:55
  • @Christian Hupfer Pie chart and tables are both convenient ways to organize data. Does the \stackon command only apply to tables? – user74973 May 28 '15 at 00:17
  • A pie chart is no table, so I am still wondering: Where's the table in your question? –  May 28 '15 at 00:20
  • @Christian Hupfer No table. May you suggest what tag to put on it? – user74973 May 28 '15 at 00:22
  • I would remove the tables tag ;-) –  May 28 '15 at 00:23
  • TikZ doesn't provide special option for name of picture as pgfplots do. If you like to have name of picture as part of picture, than simple add one node in which you put picture name. But usual for this people use caption as part of float with picture. In case, that the your picture is directly in text, then again is normally use for its name derivative of caption (i.e.: \captionof, if you use captionpackage for this). – Zarko May 28 '15 at 00:31

1 Answers1

1

Normally pictures doesn't contain titles, this is task of figure captions, something like this:

text text text
    \begin{figure}
... picture ...
    \caption{David's Monthly Expenses}
    \label{fig:david-expences}
    \end{figure}
text text text

To add picture name on picture -- as I said in my comment, you need add a node with picture title:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{angles,calc,positioning}

\begin{document}
    \begin{tikzpicture}[
every node/.style={align=center},
     pin distance=9mm
                    ]
    \coordinate (O) at (0,0);
\draw (O) circle (3);
\draw (O) -- (0:3);
\draw (O) -- (90:3);
\draw (O) -- (216:3);
\draw (O) -- (234:3);
\draw (O) -- (288:3);

\path (O) -- node{Food\\ 25\%} (45:3);
\path (O) -- node{Rent and\\ Utilities\\ 35\%} (153:3);
\path (O) -- node[pos=0.75,pin=225:Clothing\\ 5\%] {} (225:3);
\path (O) -- node{Other\\ 5\%} (261:3);
\path (O) -- node{Car\\ 20\%} (324:3);

\node[below=33mm of O] {\textbf{Title of picture}};%select one, which you more like
\node[right=33mm of O] {\textbf{Title of picture}};
    \end{tikzpicture}
\end{document}

enter image description here

Of course, bots solution has nothing with tables, except if you like to put picture in table (what wasn't state in question). For your pie chart I use my answer on one of your previous question.

Zarko
  • 296,517
  • If I want it directly above the pie chart, and centered, do I issue the command \node[above=33mm of O] {\textbf{Title of picture}};? (I guess 35mm is just as good as 33mm.) – user74973 May 28 '15 at 01:11
  • Of course. That is matter of your taste. I just show two possibilities and how to do this (if you persist to name the pictures on this way). – Zarko May 28 '15 at 01:17
  • I issue the command \path (O) -- node[align=left,pin=225:Clothing \\ 5\%] {} (225:5); and TikZ does not display what I expect. The direction of the pin is not 225 degrees; the direction looks to be about 200 degrees. Also, "5%" is not typed on the second line. It seems that "\" just removes the space between "Clothing" and "5%" to give `Clothing5%'. – user74973 May 28 '15 at 12:24
  • What part of the command \path (O) -- node[pos=0.75,pin=225:Clothing\\ 5\%] {} (225:3); instructs TikZ to draw the pin from the above right corner of the node? – user74973 May 28 '15 at 12:45
  • Sorry, I do not understood your question. This line in my MWE hasn't such instruction. It just say: center of node lie on 75% of distance from O and (225:3), pin is directed in azimuth225 degreefor9mmfrom node. Label is below this point (default features of pin). For other possibilities see questionhttp://tex.stackexchange.com/questions/246995/tikz-adjusting-pin-anchor`` – Zarko May 28 '15 at 13:01
  • Perhaps I changed the command. This is the command that I have now. \path (O) -- node[align=left,pin=225:Clothing \\ 5\%] {} (225:5);. Shouldn't "Clothing" and "5%" be put on separate lines? – user74973 May 28 '15 at 13:07
  • They already in two lines, isn't it? I suggest you to form new question with provide MWE (on basis of my answer), show your problems. This comments become discussion what is not their intention. – Zarko May 28 '15 at 13:17
  • I agree. I will do that presently, and I will send you a "ping." – user74973 May 28 '15 at 13:18
  • See the post A display in a pie chart that is not expected (or wanted). – user74973 May 28 '15 at 13:47