Chart

leather.Chart Container for all chart types.

Adding data

leather.Chart.add_series Add a data Series to the chart.
leather.Chart.add_bars Create and add a Series rendered with Bars.
leather.Chart.add_columns Create and add a Series rendered with Columns.
leather.Chart.add_dots Create and add a Series rendered with Dots.
leather.Chart.add_line Create and add a Series rendered with Line.

Rendering

leather.Chart.to_svg Render this chart to an SVG document.
leather.Chart.to_svg_group Render this chart to an SVG group element.

Detailed list

class leather.Chart(title=None)

Bases: object

Container for all chart types.

Parameters:title – An optional title that will be rendered at the top of the chart.
add_bars(data, x=None, y=None, name=None, fill_color=None)

Create and add a Series rendered with Bars.

Note that when creating bars in this way the order of the series data will be reversed so that the first item in the series is displayed as the top-most bar in the graphic. If you don’t want this to happen use Chart.add_series() instead.

add_columns(data, x=None, y=None, name=None, fill_color=None)

Create and add a Series rendered with Columns.

add_dots(data, x=None, y=None, name=None, fill_color=None, radius=None)

Create and add a Series rendered with Dots.

add_line(data, x=None, y=None, name=None, stroke_color=None, width=None)

Create and add a Series rendered with Line.

add_series(series, shape)

Add a data Series to the chart. The data types of the new series must be consistent with any series that have already been added.

There are several shortcuts for adding different types of data series. See Chart.add_bars(), Chart.add_columns(), Chart.add_dots(), and Chart.add_line().

add_x_axis(ticks=None, tick_formatter=None, name=None)

Create and add an X Axis.

If you want to set a custom axis class use Chart.set_x_axis() instead.

add_x_scale(domain_min, domain_max)

Create and add a Scale.

If the provided domain values are date or datetime then a Temporal scale will be created, otherwise it will Linear.

If you want to set a custom scale class use Chart.set_x_scale() instead.

add_y_axis(ticks=None, tick_formatter=None, name=None)

See Chart.add_x_axis().

add_y_scale(domain_min, domain_max)

See Chart.add_x_scale().

set_x_axis(axis)

Set an Axis class for this chart.

set_x_scale(scale)

Set the X Scale for this chart.

set_y_axis(axis)

See Chart.set_x_axis().

set_y_scale(scale)

See Chart.set_x_scale().

to_svg(path=None, width=None, height=None)

Render this chart to an SVG document.

The width and height are specified in SVG’s “unitless” units, however, it is usually convenient to specify them as though they were pixels.

Parameters:
  • path – Filepath or file-like object to write to. If omitted then the SVG will be returned as a string. If running within IPython, then this will return a SVG object to be displayed.
  • width – The output width, in SVG user units. Defaults to theme.default_chart_width.
  • height – The output height, in SVG user units. Defaults to theme.default_chart_height.
to_svg_group(width=None, height=None)

Render this chart to an SVG group element.

This can then be placed inside an <svg> tag to make a complete SVG graphic.

See Chart.to_svg() for arguments.