Pie Chart with ZedGraph

For details of the ZedGraph libray see Multi-colored Bar Chart with ZedGraph.

This example creates a Pie chart and saves it to a file.

import clr clr.AddReference('ZedGraph') clr.AddReference('System.Drawing')

from ZedGraph import GraphPane from System.Drawing import Bitmap, Color, Graphics, RectangleF from System.Drawing.Imaging import ImageFormat

pane = GraphPane(RectangleF(0, 0, 500, 420), "Mood News", "", "") pane.Border.IsVisible = False pane.Legend.IsVisible = False

pane.AddPieSlice(101, Color.Green, 0.03, "Good") pane.AddPieSlice(101, Color.Red, 0.03, "Bad") pane.AddPieSlice(101, Color.Blue, 0.03, "Neutral") pane.AddPieSlice(101, Color.Gray, 0.03, "Don't Know")

bm = Bitmap(1, 1) g = Graphics.FromImage(bm) pane.AxisChange(g) pane.GetImage.Save('example.png', ImageFormat.Png)

Back to Contents.