Charts (Pie and Bar)

In Ziaplot, the term “chart” is used for figures where the x value is qualitative. This includes Pie charts and bar charts.

Bar Chart

To build a bar chart from ziaplot.bar.BarChart, the x values must be provided when the BarChart is instantiated. Sets of bars are added using ziaplot.bar.BarChart.bar(), which automatically creates and adds a ziaplot.dataseries.Bars series.

p = zp.BarChart(['January', 'February', 'March'])
p.bar((4, 4, 5, 6)).name('Apple')
p.bar((3, 4, 4, 5)).name('Blueberry')
p.bar((2, 1, 5, 4)).name('Cherry')
p
_images/charts_1_0.svg

Bar charts may also be drawn with horizontal bars.

p = zp.BarChart(['January', 'February', 'March'], horiz=True)
p.bar((4, 4, 5, 6)).name('Apple')
p.bar((3, 4, 4, 5)).name('Blueberry')
p.bar((2, 1, 5, 4)).name('Cherry')
p
_images/charts_2_0.svg

Pie Chart

ziaplot.pie.Pie charts consist of wedges that are added to the pie using the ziaplot.pie.Pie.wedge() method. Note the use of extrude to pull a single pie wedge out from the center.

p = zp.Pie()
p.wedge(3, 'a', extrude=True)
p.wedge(10, 'b')
p.wedge(5, 'c', color='green')
p
_images/charts_3_0.svg

Or multiple wedges added at once using wedges:

zp.Pie().wedges(20, 30, 40, 10).names('a', 'b', 'c', 'd')
_images/charts_4_0.svg