Skip to content

Commit

Permalink
Replace TikZ samples for Asymptote samples
Browse files Browse the repository at this point in the history
The plot generator is not getting replaced as Asymptote features a much more
powerful module.
  • Loading branch information
Ambrevar committed Jan 8, 2015
1 parent 690a885 commit f9179fd
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 144 deletions.
34 changes: 34 additions & 0 deletions .asy/piechart.asy
Original file line number Diff line number Diff line change
@@ -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;
}

1 change: 0 additions & 1 deletion .texmf/tex/latex/pie.tex

This file was deleted.

85 changes: 0 additions & 85 deletions .texmf/tex/latex/piegen.tex

This file was deleted.

4 changes: 0 additions & 4 deletions .texmf/tex/latex/plot.tex

This file was deleted.

54 changes: 0 additions & 54 deletions .texmf/tex/latex/plotgen.tex

This file was deleted.

0 comments on commit f9179fd

Please sign in to comment.