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.
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()
'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,
)
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()