I want to create a pie-chart. Is that possible with gnuplot and how to realize that?
Best Answer
Here's an example of a pie-chart created with gnuplot. Also, on the same site, you can find another example, including the script used for creating the pie-chart.
You'll first need to count the number of male and female entries, then make a pie chart out of that data.
In OpenOffice.org Calc I was able to use the COUNTIF function to count the entries, then select the counts and make a pie chart from that. It should be similar in Excel.
data = {
# partition: (frac of disk, frac full)
"/": (0.3, 0.9),
"/home": (0.7, 0.1),
}
Try using the reportlab.graphics library (available from the Ubuntu and Fedora repositories as python-reportlab):
from reportlab.graphics.shapes import Drawing
from reportlab.graphics.charts.piecharts import Pie
from reportlab.graphics import renderSVG
from itertools import chain
d = Drawing(400, 400)
outerPie = Pie()
outerPie.x = outerPie.y = 0
outerPie.width = outerPie.height = 400
# 2 slices for each sector (used, unused)
outerPie.data = list(chain(*[
[fracDisk * fracPart, fracDisk * (1 - fracPart)]
for (fracDisk, fracPart) in data.values()]))
d.add(outerPie, '')
# Draw smaller pie chart on top of outerPie, leaving outerPie as a ring
innerPie = Pie()
innerPie.x = innerPie.y = 100
innerPie.width = innerPie.height = 200
innerPie.data = [t[0] for t in data.values()]
innerPie.labels = list(data)
d.add(innerPie, '')
renderSVG.drawToFile(d, 'chart.svg')
Best Answer
Here's an example of a pie-chart created with gnuplot. Also, on the same site, you can find another example, including the script used for creating the pie-chart.