How to use the leather.Dots function in leather

To help you get started, we’ve selected a few leather examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wireservice / leather / tests / test_shapes.py View on Github external
def setUp(self):
        self.shape = leather.Dots('red')
        self.linear = leather.Linear(0, 10)
        self.ordinal = leather.Ordinal(['foo', 'bar', 'bing'])
        self.palette = (color for color in ['red', 'white', 'blue'])
github wireservice / agate / agate / tableset / scatterplot.py View on Github external
:param width:
        The width of the output SVG.
    :param height:
        The height of the output SVG.
    """
    if type(x) is int:
        x_name = self.column_names[x]
    else:
        x_name = x

    if type(y) is int:
        y_name = self.column_names[y]
    else:
        y_name = y

    chart = leather.Lattice(shape=leather.Dots())
    chart.add_x_axis(name=x_name)
    chart.add_y_axis(name=y_name)
    chart.add_many(self.values(), x=x, y=y, titles=self.keys())

    return chart.to_svg(path=path, width=width, height=height)
github OpenNewsLabs / onechart-twelvechartinglibraries / leather / scatterplot.py View on Github external
import leather
import math
import csv

chart = leather.Chart('Income vs. health')

with open('data.csv', 'r') as csvfile:
    reader = csv.DictReader(csvfile)
    data = list(reader)
    
    def size_dot_by_area(x, y, i):
        return math.sqrt(int(data[i]['population'])) / 1000

    dots = leather.Dots('rgba(0,0,0,0.5)', radius=size_dot_by_area)

    series = leather.Series(
        data,
        dots,
        x=lambda row, i: math.log(float(row['income'])),
        y=lambda row, i: float(row['health']))

    chart.add_series(series)

chart.set_x_axis(leather.Axis(name='Log GDP per capita'))
chart.set_y_axis(leather.Axis(name='Life expectancy in years'))
chart.to_svg('chart.svg')