Bar charts#
- class sage.plot.bar_chart.BarChart(ind, datalist, options)#
Bases:
GraphicPrimitive
Graphics primitive that represents a bar chart.
EXAMPLES:
sage: from sage.plot.bar_chart import BarChart sage: g = BarChart(list(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, width=0.5, rgbcolor=(0, 0, 1), legend_label=None, aspect_ratio='automatic', **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]) Graphics object consisting of 1 graphics primitive
A bar_chart with thinner bars:
sage: bar_chart([x^2 for x in range(1,20)], width=0.2) Graphics object consisting of 1 graphics primitive
A bar_chart with negative values and red bars:
sage: bar_chart([-3,5,-6,11], rgbcolor=(1,0,0)) Graphics object consisting of 1 graphics primitive
A bar chart with a legend (it’s possible, not necessarily useful):
sage: bar_chart([-1,1,-1,1], legend_label='wave') Graphics object consisting of 1 graphics primitive
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) Graphics object consisting of 1 graphics primitive sage: bar_chart([-2,8,-7,3], rgbcolor=(1,0,0)).show(axes=False) # These are equivalent