Skip to content

Commit

Permalink
Make examples easier to work with. #43.
Browse files Browse the repository at this point in the history
  • Loading branch information
onyxfish committed May 20, 2016
1 parent bbb3d72 commit 3d6918f
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 64 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ build
.proof
.ipynb_checkpoints
.idea
examples/charts
4 changes: 0 additions & 4 deletions docs/example.svg

This file was deleted.

4 changes: 0 additions & 4 deletions docs/example2.svg

This file was deleted.

31 changes: 6 additions & 25 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,15 @@ Show me docs
Show me code
============

.. code-block:: python
.. literalinclude:: ../examples/lines.py
:language: python

data = [
(0, 3),
(4, 5),
(7, 9),
(8, 4)
]
.. figure:: ../examples/charts/lines.svg

chart = leather.Chart()
chart.add_lines(data)
chart.add_dots(data)
chart.to_svg('example.svg')
.. literalinclude:: ../examples/colorized_dots.py
:language: python

.. figure:: example.svg

.. code-block:: python
dot_data = [(random.randint(0, 250), random.randint(0, 250)) for i in range(100)]
def colorizer(x, y, i):
return 'rgb(%i, %i, %i)' % (x, y, 150)
chart = leather.Chart('Something a little fancier')
chart.add_dots(dot_data, color=colorizer)
chart.to_svg('docs/example2.svg')
.. figure:: example2.svg
.. figure:: ../examples/charts/colorized_dots.svg

Join us
=======
Expand Down
30 changes: 0 additions & 30 deletions example.py

This file was deleted.

8 changes: 8 additions & 0 deletions examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

export PYTHONPATH="$PYTHONPATH:$(pwd)"

for f in examples/*.py; do
echo $f
python $f
done
Empty file added examples/charts/.placeholder
Empty file.
13 changes: 13 additions & 0 deletions examples/colorized_dots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import random

import leather


dot_data = [(random.randint(0, 250), random.randint(0, 250)) for i in range(100)]

def colorizer(x, y, i):
return 'rgb(%i, %i, %i)' % (x, y, 150)

chart = leather.Chart('Colorized dots')
chart.add_dots(dot_data, color=colorizer)
chart.to_svg('examples/charts/colorized_dots.svg')
12 changes: 12 additions & 0 deletions examples/lines.py
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('Lines')
chart.add_lines(data)
chart.to_svg('examples/charts/lines.svg')
54 changes: 54 additions & 0 deletions examples/realdata/Datagov_FY10_EDU_recp_by_State.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
State Name,State Abbreviate,Post-9/11GI Bill Program,Montgomery GI Bill - Active Duty,Montgomery GI Bill - Selective Reserve,Dependents' Educational Assistance,Reserve Educational Assistance Program,Post-Vietnam Era Veteran's Educational Assistance Program,TOTAL
ALABAMA,AL,7738,5779,2075,3102,883,5,"19,582"
ALASKA,AK,1781,561,170,164,28,1,"2,705"
ARIZONA,AZ,18588,21012,2132,3571,1433,7,"46,743"
ARKANSAS,AR,2579,1639,1219,1760,733,2,"7,932"
CALIFORNIA,CA,44906,20642,2977,7283,800,31,"76,639"
COLORADO,CO,11379,6987,905,1735,472,7,"21,485"
CONNECTICUT,CT,2208,1169,507,412,51,3,"4,350"
DELAWARE,DE,1061,374,176,238,54,1,"1,904"
DIST. OF COLUMBIA,DC,1485,434,50,191,23,2,"2,185"
FLORIDA,FL,28292,20414,2986,6582,1227,18,"59,519"
GEORGIA,GA,12464,9303,2473,3765,618,8,"28,631"
HAWAII,HI,4012,802,352,444,87,2,"5,699"
IDAHO,ID,1576,1134,618,423,193,1,"3,945"
ILLINOIS,IL,13522,12000,2653,2218,1602,12,"32,007"
INDIANA,IN,5061,2925,1892,1249,840,5,"11,972"
IOWA,IA,4640,6237,1834,889,887,3,"14,490"
KANSAS,KS,3495,2354,797,680,415,3,"7,744"
KENTUCKY,KY,3852,2282,1130,1819,502,4,"9,589"
LOUISIANA,LA,3992,2357,1222,1564,390,3,"9,528"
MAINE,ME,1144,535,286,699,68,1,"2,733"
MARYLAND,MD,11006,5022,683,1115,244,8,"18,078"
MASSACHUSETTS,MA,4644,1947,854,1047,293,7,"8,792"
MICHIGAN,MI,6634,3426,1439,1805,444,11,"13,759"
MINNESOTA,MN,7125,3698,1957,1625,762,7,"15,174"
MISSISSIPPI,MS,2928,1307,1428,916,571,2,"7,152"
MISSOURI,MO,7512,7831,2154,1673,1643,8,"20,821"
MONTANA,MT,1251,651,372,359,78,1,"2,712"
NEBRASKA,NE,2483,2295,854,854,404,2,"6,892"
NEVADA,NV,2919,1711,411,589,97,1,"5,728"
NEW HAMPSHIRE,NH,1101,425,245,264,54,1,"2,090"
NEW JERSEY,NJ,4619,2274,947,901,312,5,"9,058"
NEW MEXICO,NM,2372,2116,462,1322,126,3,"6,401"
NEW YORK,NY,12199,5420,1937,2517,591,14,"22,678"
NORTH CAROLINA,NC,10068,7973,1598,4267,595,7,"24,508"
NORTH DAKOTA,ND,857,519,529,259,255,1,"2,420"
OHIO,OH,8994,5295,3160,1991,1174,11,"20,625"
OKLAHOMA,OK,4129,3943,1418,2314,900,4,"12,708"
OREGON,OR,3937,2437,638,1382,218,4,"8,616"
PENNSYLVANIA,PA,11815,4904,2353,2225,690,11,"21,998"
RHODE ISLAND,RI,953,333,238,243,80,1,"1,848"
SOUTH CAROLINA,SC,6067,2852,1597,2195,341,4,"13,056"
SOUTH DAKOTA,SD,826,564,684,284,226,1,"2,585"
TENNESSEE,TN,6613,3430,1382,1829,481,5,"13,740"
TEXAS,TX,35596,19027,3244,8041,1089,18,"67,015"
UTAH,UT,3133,2250,1170,744,533,2,"7,832"
VERMONT,VT,690,316,104,125,37,0,"1,272"
VIRGINIA,VA,26426,10092,1549,3322,693,10,"42,092"
WASHINGTON,WA,10231,5059,743,2381,307,8,"18,729"
WEST VIRGINIA,WV,4145,5834,1075,840,1022,1,"12,917"
WISCONSIN,WI,5436,3131,1509,1402,825,5,"12,308"
WYOMING,WY,464,561,227,150,84,1,"1,487"
PUERTO RICO,PR,957,635,1285,1580,670,2,"5,129"
PHILIPPINES,PH,171,291,0,10,0,0,472
2 changes: 1 addition & 1 deletion leather/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from leather.grid import Grid
from leather.lattice import Lattice
from leather.legend import Legend
from leather.scales import Scale, Linear, Ordinal
from leather.scales import Scale, Linear, Ordinal, Temporal
from leather.series import Series
from leather.shapes import Shape, Bars, Columns, Dots, Lines
from leather import theme

0 comments on commit 3d6918f

Please sign in to comment.