Re: Le mie (dis)avventure con TikZ

#96792
lorenzo.pantieri
Partecipante
    Up
    0
    Down
    ::

    lorenzo.pantieri” post=99123E ancora: vorrei fare un diagramma a torta con i dati rappresentati nel post precedente. Li riporto anche in tabella.
    `\begin{tabular}{cc}
    \toprule
    Altezza & Numero \\
    & ragazzi \\
    \midrule
    $138$ & $1$ \\
    $140$ & $3$ \\
    $145$ & $5$ \\
    $148$ & $3$ \\
    $149$ & $4$ \\
    $151$ & $3$ \\
    $152$ & $1$ \\
    \textbf{Totale} & $\boldsymbol{20}$ \\
    \bottomrule
    \end{tabular}
    `
    Qual è il modo migliore per farlo?

    Ho provato così.
    `\begin{tikzpicture}[x=7mm,y=7mm, x radius=7mm, y radius=7mm]
    \draw (0,0) circle (3);
    \draw [fill=orange] (0,0) — (0:3) arc (0:18:3);
    \draw [fill=brown] (0,0)– (18:3) arc (18:72:3);
    \draw [fill=green] (0,0)– (72:3) arc (72:162:3);
    \draw [fill=red] (0,0)– (162.6:3) arc (162:216:3);
    \draw [fill=blue] (0,0)– (216:3) arc (216:288:3);
    \draw [fill=olive] (0,0)– (288:3) arc (288:342:3);
    \draw [fill=lightgray] (0,0)– (342:3) arc (342:360:3);

    \node at (0,4) {Areogramma};

    \begin{scope}[xshift=28mm,every node/.style={ anchor=center}]

    \matrix[matrix of nodes] at (0,0){
    \node[fill=orange]{}; & $1$ \\
    \node[fill=brown]{}; & $3$ \\
    \node[fill=green]{}; & $5$ \\
    \node[fill=red]{}; & $3$ \\
    \node[fill=blue]{}; & $4$ \\
    \node[fill=olive]{}; & $3$ \\
    \node[fill=lightgray]{}; & $1$ \\
    };
    \end{scope}
    \end{tikzpicture}
    `
    La torta per esserci c’è, ma è un diagramma brutto brutto brutto. Suggerimenti per migliorare il codice?

    Go to top