-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
161 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
======== | ||
Examples | ||
======== | ||
|
||
Data | ||
==== | ||
|
||
Simple pairs | ||
------------ | ||
|
||
.. literalinclude:: ../examples/simple_pairs.py | ||
:language: python | ||
|
||
.. figure:: ../examples/charts/simple_pairs.svg | ||
|
||
Table from csv.reader | ||
--------------------- | ||
|
||
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 <http://agate.rtfd.io/>`_ | ||
|
||
.. literalinclude:: ../examples/csv_reader.py | ||
:language: python | ||
|
||
.. figure:: ../examples/charts/csv_reader.svg | ||
|
||
Table from csv.DictReader | ||
------------------------- | ||
|
||
See previous example for note on strings from CSVs. | ||
|
||
.. literalinclude:: ../examples/csv_dict_reader.py | ||
:language: python | ||
|
||
.. figure:: ../examples/charts/csv_dict_reader.svg | ||
|
||
Custom data | ||
----------- | ||
|
||
TKTK | ||
|
||
Shapes | ||
====== | ||
|
||
Bars | ||
---- | ||
|
||
TKTK | ||
|
||
Columns | ||
------- | ||
|
||
TKTK | ||
|
||
Dots | ||
---- | ||
|
||
TKTK | ||
|
||
Lines | ||
----- | ||
|
||
.. literalinclude:: ../examples/lines.py | ||
:language: python | ||
|
||
.. figure:: ../examples/charts/lines.svg | ||
|
||
Scales | ||
====== | ||
|
||
TKTK | ||
|
||
Axes | ||
==== | ||
|
||
TKTK | ||
|
||
Styling | ||
======= | ||
|
||
TKTK | ||
|
||
|
||
.. literalinclude:: ../examples/colorized_dots.py | ||
:language: python | ||
|
||
.. figure:: ../examples/charts/colorized_dots.svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import csv | ||
|
||
import leather | ||
|
||
with open('examples/realdata/gii.csv') as f: | ||
reader = csv.DictReader(f) | ||
data = list(reader)[:10] | ||
|
||
for row in data: | ||
mmr = row['Maternal mortality ratio'] | ||
row['Maternal mortality ratio'] = float(mmr) if mmr is not None else None | ||
|
||
chart = leather.Chart('Data from CSV reader') | ||
chart.add_bars(data, x='Maternal mortality ratio', y='Country') | ||
chart.to_svg('examples/charts/csv_dict_reader.svg') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import csv | ||
|
||
import leather | ||
|
||
with open('examples/realdata/gii.csv') as f: | ||
reader = csv.reader(f) | ||
next(reader) | ||
data = list(reader)[:10] | ||
|
||
for row in data: | ||
row[1] = float(row[1]) if row[1] is not None else None | ||
|
||
chart = leather.Chart('Data from CSV reader') | ||
chart.add_bars(data, x=1, y=0) | ||
chart.to_svg('examples/charts/csv_reader.svg') |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## gii.csv | ||
|
||
A subset of data taken from the UN's [Gender Inequality Index](http://hdr.undp.org/en/composite/GII). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import leather | ||
|
||
data = [ | ||
(0, 3), | ||
(4, 5), | ||
(7, 9), | ||
(8, 4) | ||
] | ||
|
||
chart = leather.Chart('Simple pairs') | ||
chart.add_dots(data) | ||
chart.to_svg('examples/charts/simple_pairs.svg') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
#!/usr/bin/env python | ||
|
||
from datetime import date, datetime | ||
import csv | ||
|
||
import leather | ||
|
||
with open('examples/realdata/gii.csv') as f: | ||
reader = csv.reader(f) | ||
next(reader) | ||
|
||
data = [ | ||
(datetime(2010, 1, 1), 4), | ||
(datetime(2011, 5, 4), 3), | ||
(datetime(2012, 6, 1, 11), 5), | ||
(datetime(2013, 1, 1), 6), | ||
(datetime(2014, 12, 1), 10) | ||
] | ||
data = list(reader)[:10] | ||
|
||
chart = leather.Chart("X axis ftw") | ||
chart.add_lines(data) | ||
chart = leather.Chart('Test') | ||
chart.add_bars(data, x=1, y=0) | ||
chart.to_svg('test.svg') |