Skip to content

Latest commit

 

History

History
216 lines (132 loc) · 5.19 KB

examples.rst

File metadata and controls

216 lines (132 loc) · 5.19 KB

Examples

Data series

Simple pairs

../examples/simple_pairs.py

Table from csv.reader

Sequence row data, such as is returned by csv.reader can be accessed by specifying the indices of the columns containing the x and y values.

Note that leather does not automatically convert numerical strings, such as those stored in a CSV. If you want that you'll need to use a smarter table reader, such as agate

../examples/csv_reader.py

Table from csv.DictReader

Dict row data, such as is returned by csv.DictReader can be accessed by specifying the indices of the columns containing the x and y values.

See previous example for note on strings from CSVs.

../examples/csv_dict_reader.py

Custom data

Completely custom data formats are also supported via accessor functions.

../examples/custom_data.py

Multiple series

Multiple data series can be displayed on a single chart so long as they all use the same type of .Scale.

../examples/multiple_series.py

Shapes

Bars

../examples/bars.py

Columns

../examples/columns.py

Dots

../examples/dots.py

Lines

../examples/lines.py

Mixing shapes

You can mix different shapes for different series on the same chart.

../examples/mixed_shapes.py

Scales

Linear

When using numerical data .Linear scales are created automatically and by default. You may override the domain by adding a scale manually.

../examples/linear.py

Ordinal

When using text data .Ordinal scales are created automatically and by default. It is generally not useful to override these defaults.

../examples/ordinal.py

Temporal

When using date/time data .Temporal scales are created automatically and by default. You may override the domain by adding a scale manually.

../examples/temporal.py

Axes

Changing tick values

You can change the list of ticks that are displayed using .Chart.add_x_axis and .Chart.add_y_axis methods. This will not adjust automatically adjust the scale, so it is possible to pick tick values that are not displayed.

../examples/ticks.py

Customizing tick format

You can provide a tick formatter method to change how ticks are displayed using the .Chart.add_x_axis and .Chart.add_y_axis methods.

../examples/tick_format.py

Styling

Changing theme values

Chart styles are set using a dead simple .theme system. Leather is meant for making quick and dirty charts. It is neither expected nor recommended for user's to customize these styles.

../examples/theme.py

Changing series colors

More practically, individual default .Series colors can be overridden when they are created.

../examples/series_color.py

Styling data based on value

Style attributes of individual data points can be set by value using a .style_function.

../examples/colorized_dots.py

Chart grids

With mixed scales

You can add charts of completely different types to a single graphic by using .Grid.

../examples/grid.py

With consistent scales

A grid of charts can automatically be synchronized to a consistent view using .Lattice.

../examples/lattice.py