Skip to content

A data visualization style based on the City of Philadelphia Digital Standards

License

Notifications You must be signed in to change notification settings

PhilaController/phila-style

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

phila-style

Build Status t PyPi version

A data visualization style based on the City of Philadelphia Digital Standards. Matplotlib and Altair themes are included by default.

The theme requires the Open Sans font to be installed.

Light Mode

Light Mode

Grey Mode

Grey Mode

Color palettes

The default color palette is slightly tweaked from the palette defined by the Digital Standards. The list of colors can be retrieved using:

from phila_style import *

# default color palette with light/dark variations
default = get_default_palette()
light = get_light_palette()
dark = get_dark_palette()

Sequential color ramps can be constructed for any of the colors in the default color palettes. The color from the palette will be the midpoint of the color ramp.

# get color ramp
ramp = get_color_ramp("blue", N=9)

All colors defined by the Digital Standards palette can also be loaded:

standard = get_digital_standards()

Matplotlib theme

'Dark', 'grey', and 'light' modes are available. Below is an example of the 'grey' theme:

from matplotlib import pyplot as plt
import numpy as np
from phila_style.matplotlib import get_theme

with plt.style.context(get_theme(mode="grey")):
    for i in range(7):
        plt.plot(np.random.random(size=10))

    plt.gcf().text(
        0.005,
        0.95,
        "An Example of the City of Philadelphia 'Grey' Matplotlib Theme",
        weight="bold",
        fontsize=14,
    )

Matplotlib Grey Mode

Altair theme

Heavily inspired by the LA Times Altair theme, but using the recommended color palette from the City of Philadelphia's Digital Standards.

Currently, only the light theme is available.

from phila_style.altair as get_theme
import altair as alt

# register and enable the theme
alt.themes.register('phila', get_theme)
alt.themes.enable('phila')
from vega_datasets import data
source = data.cars()

alt.Chart(source).mark_circle(size=60).encode(
    x='Horsepower',
    y='Miles_per_Gallon',
    color='Origin',
    tooltip=['Name', 'Origin', 'Horsepower', 'Miles_per_Gallon']
).interactive()

Altair example

About

A data visualization style based on the City of Philadelphia Digital Standards

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages