Bar Charts

class sage.plot.bar_chart.BarChart(ind, datalist, options)

Bases: sage.plot.primitive.GraphicPrimitive

Graphics primitive that represents a bar chart.

EXAMPLES:

sage: from sage.plot.bar_chart import BarChart
sage: g = BarChart(range(4), [1,3,2,0], {}); g
BarChart defined by a 4 datalist
sage: type(g)
<class 'sage.plot.bar_chart.BarChart'>
get_minmax_data()

Returns a dictionary with the bounding box data.

EXAMPLES:

sage: b = bar_chart([-2.3,5,-6,12])
sage: d = b.get_minmax_data()
sage: d['xmin']
0
sage: d['xmax']
4
sage.plot.bar_chart.bar_chart(datalist, aspect_ratio='automatic', width=0.5, legend_label=None, rgbcolor=(0, 0, 1), **options)

A bar chart of (currently) one list of numerical data. Support for more data lists in progress.

EXAMPLES:

A bar_chart with blue bars:

sage: bar_chart([1,2,3,4])

A bar_chart with thinner bars:

sage: bar_chart([x^2 for x in range(1,20)], width=0.2)

A bar_chart with negative values and red bars:

sage: bar_chart([-3,5,-6,11], rgbcolor=(1,0,0))

A bar chart with a legend (it’s possible, not necessarily useful):

sage: bar_chart([-1,1,-1,1], legend_label='wave')

Extra options will get passed on to show(), as long as they are valid:

sage: bar_chart([-2,8,-7,3], rgbcolor=(1,0,0), axes=False)
sage: bar_chart([-2,8,-7,3], rgbcolor=(1,0,0)).show(axes=False) # These are equivalent

Previous topic

Arrows

Next topic

Bezier Paths

This Page