diff --git a/.asy/piechart.asy b/.asy/piechart.asy new file mode 100644 index 00000000..dc03e8dc --- /dev/null +++ b/.asy/piechart.asy @@ -0,0 +1,34 @@ +/* Example of use: + +access piechart; +unitsize (70); + +int[] values = {1, 2, 3, 2}; +string[] labels = {"a", "b", "c", "very long"}; + +add(piechart.pie(values, labels, 1.2, green, labelcolor=blue)); +*/ + +picture pie (int[] values, string[] labels={}, real distance = 0.5, pen color = rgb(1,1,1), pen labelcolor = rgb(0, 0, 0)) { + picture opic; + // unitsize(100); + int total = 0; + for (int i: values) { + total += i; + } + + if (total != 0) { + real last = 0; + for (int i = 0; i < values.length; ++i) { + real current = last+values[i]*360/total; + filldraw(opic, arc((0,0), 1, last, current) -- (0,0) -- cycle, values[i]/total * color); + if (labels.length == values.length) { + // rotate() 0 angle is upwards. We shift it to match the trigonometric circle. + label (opic, labels[i], rotate((current+last)/2-90) * (0, distance), labelcolor); + } + last = current; + } + } + return opic; +} + diff --git a/.texmf/tex/latex/pie.tex b/.texmf/tex/latex/pie.tex deleted file mode 100644 index 75fd98ec..00000000 --- a/.texmf/tex/latex/pie.tex +++ /dev/null @@ -1 +0,0 @@ -\piechart{color}{scale}{value1/label1, value2/label2, ...} diff --git a/.texmf/tex/latex/piegen.tex b/.texmf/tex/latex/piegen.tex deleted file mode 100644 index 4c9ab2b3..00000000 --- a/.texmf/tex/latex/piegen.tex +++ /dev/null @@ -1,85 +0,0 @@ -% pie chart generator - -\newcounter{pieSlicePercentage} -\newcounter{pieCounterCurrent} -\newcounter{pieCounterNext} -\newcounter{pieCounterTotal} - -\newcommand{\pieslice}[3]{ - \pgfmathparse{0.5*#1+0.5*#2} - \let\midangle\pgfmathresult - - \setcounter{pieSlicePercentage}{\p*100/\thepieCounterTotal} - - % slice - \draw[thick,fill=#3!\thepieSlicePercentage] (0,0) -- (#1:1) arc (#1:#2:1) -- cycle; -} - -\newcommand{\pieslicelabel}[3]{ - \pgfmathparse{0.5*#1+0.5*#2} - \let\midangle\pgfmathresult - - \setcounter{pieSlicePercentage}{\p*100/\thepieCounterTotal} - - % Outer label. - \pgfmathparse{min((#2-#1-10)/110*(-0.3),0)} - \let\temp\pgfmathresult - \pgfmathparse{max(\temp,-0.5) + 1.55} - \let\outerpos\pgfmathresult - \node at (\midangle:\outerpos) {\textbf{#3}}; - - % Inner label. - \pgfmathparse{min((#2-#1-10)/110*(-0.3),0)} - \let\temp\pgfmathresult - \pgfmathparse{max(\temp,-0.5) + 0.8} - \let\innerpos\pgfmathresult - - \node at (\midangle:\innerpos) {\thepieSlicePercentage \%}; -} - -\newcommand{\piechart}[3]{ - \setcounter{pieCounterCurrent}{0} - \setcounter{pieCounterNext}{0} - \setcounter{pieCounterTotal}{0} - - \begin{center} - - \begin{tikzpicture}[scale=#2] - - %% Get the total to turn the values into percentages. - \foreach \p/\t in {#3} { - \setcounter{pieCounterTotal}{\thepieCounterTotal+\p} - } - - %% Draw the slices. - \foreach \p/\t in {#3} { - \setcounter{pieCounterCurrent}{\value{pieCounterNext}} - \addtocounter{pieCounterNext}{\p} - \pieslice{ - \thepieCounterCurrent/\thepieCounterTotal*360 - }{ - \thepieCounterNext/\thepieCounterTotal*360 - }{ - #1 - } - } - - \setcounter{pieCounterCurrent}{0} - \setcounter{pieCounterNext}{0} - - %% Write the labels. - \foreach \p/\t in {#3}{ - \setcounter{pieCounterCurrent}{\value{pieCounterNext}} - \addtocounter{pieCounterNext}{\p} - \pieslicelabel{ - \thepieCounterCurrent/\thepieCounterTotal*360 - }{ - \thepieCounterNext/\thepieCounterTotal*360 - }{ - \t - } - } - - \end{tikzpicture} - \end{center} -} diff --git a/.texmf/tex/latex/plot.tex b/.texmf/tex/latex/plot.tex deleted file mode 100644 index 970f9854..00000000 --- a/.texmf/tex/latex/plot.tex +++ /dev/null @@ -1,4 +0,0 @@ -\\plottype{plotname}% -{abscissa legend} -{ordinate legend} - diff --git a/.texmf/tex/latex/plotgen.tex b/.texmf/tex/latex/plotgen.tex deleted file mode 100644 index 75adfb05..00000000 --- a/.texmf/tex/latex/plotgen.tex +++ /dev/null @@ -1,54 +0,0 @@ -% name: plot generator -\newcommand{\\${1}}[7]{ - - \begin{figure}[h!] - \caption{#1} - \begin{center} - \begin{tikzpicture}[scale=0.5,x=1cm,y=0.15cm] - - %% User parameters. - \def\xmin{0} - \def\xmax{10} - \def\ymin{0} - \def\ymax{60} - \def\xstep{1} - \def\ystep{10} - - %% Grid - \draw[style=help lines, ystep=\ystep, xstep=\xstep] (\xmin,\ymin) grid - (\xmax,\ymax); - - %% Axes - \draw[->] (\xmin,\ymin) -- (\xmax+0.5*\xstep,\ymin) - node[below,yshift=-1em] {#2}; - - \draw[->] (\xmin,\ymin) -- (\xmin,\ymax+0.5*\ystep) - node[above] {#3}; - - %% xticks and yticks - \foreach \x in {\xmin,\xstep,...,\xmax} - \node at (\x, \ymin) [below] {\x}; - \foreach \y in {\ymin,\ystep,...,\ymax} - \node at (\xmin,\y) [left] {\y}; - - %% DATA - %% Example from file. - %% Smooth the curve and mark the data point with a dot. - %% Data should be stored as - %% x1 y1 - %% x2 y2 - % \draw[color=blue] - % plot[smooth,mark=*,mark size=1pt, id=iter_sorted] - % file {#5} - % node [right] {#4}; - - %% Example trendline - %% \draw[color=orange,domain=\xmin+\xstep:\xmax] - %% plot[smooth, raw gnuplot, id=trend3] - %% function{f(x)=a*x*log(x)+b; fit f(x) '#5' via a,b; plot f(x)} - %% node [right,yshift=1em] {$\alpha_1 \cdot n\cdot \log(n) + \beta_1$}; - $0 - \end{tikzpicture} - \end{center} - \end{figure} -}