Hi

i needed to test this, so i adapted to octave the x13.c taken
from plplot 5.9.2 (ubuntu)

Feel free to remove my name from the file, it is not a great contribution :)

Best regards
Alain Baeckeroot
# x13.m
# retranscription of x13.c 2010-01-12 alain.baecker...@laposte.net

#	Pie chart demo.


text= [
"Maurice",
"Geoffrey",
"Alan",
"Rafael",
"Vince"
];

#--------------------------------------------------------------------------
# Does a simple pie chart.
#--------------------------------------------------------------------------

x=zeros(500,1);
y=x;
per=x;;

per(1) = 10.; # percentage, total = 100
per(2) = 32.;
per(3) = 12.;
per(4) = 30.;
per(5) = 16.;

xc = 5.; # center the pie in (5, 5)
yc = 5.;

# Initialize plplot

plinit();

pladv(0);
# Ensure window has aspect ratio of one so circle is
# plotted as a circle.
plvasp(1.0);
plwind(0., 10., 0., 10.);
# plenv(0., 10., 0., 10., 1, -2);
plcol0(2);
# n.b. all theta quantities scaled by 2*M_PI/500 to be integers to avoid
# floating point logic problems.
theta0 = 0;
dthet = 1;
for ii = 1:5
	jj = 1;
	x(jj) = xc;
	y(jj++) = yc;
	# n.b. the theta quantities multiiplied by 2*pi/500 afterward so
	#  in fact per is interpreted as a percentage.
	theta1 = round(theta0 + 5 * per(ii));
	if (ii == 5)
		theta1 = 500;
	endif;

	for theta = theta0:dthet:theta1
		x(jj) = xc + 3 * cos((2.*pi/500.)*theta);
		y(jj++) = yc + 3 * sin((2.*pi/500.)*theta);
	endfor;

	xx =  x(1:jj-1);
	yy =  y(1:jj-1);
	plcol0(ii + 1);
	# comment the following line to fill with plain colors instead of lines
	plpsty(mod((ii + 3), 8) + 1);
	plfill(xx, yy);
	plcol0(1);
	plline(xx, yy);
	just = (2.*pi/500.)*(theta0 + theta1)/2.;
	dx = .25 * cos(just);
	dy = .25 * sin(just);
	if ((theta0 + theta1)  < 250 || (theta0 + theta1) > 750)
		just = 0.;
	else
		just = 1.;
	endif

	plptex( (x(round(jj / 2)) + dx), (y(round(jj / 2)) + dy), 1.0, 0.0, just, text(ii));
	theta0 = theta - dthet;
endfor;
plfont(2);
plschr(0., 1.3);
plptex(5.0, 9.0, 1.0, 0.0, 0.5, "Percentage of Sales");

# Don't forget to call PLEND to finish off! */

plend();
exit(0);

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Plplot-general mailing list
Plplot-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-general

Reply via email to