Croissant
A croissant chart of the standard normal distribution: the density curve cut at its quintiles into five slices of equal probability, each with a dot at its median, in the colors of the paper's anatomy figure.
python
from gofish import Bin, Calendar, Dist, Spacing, Unit, chart, circle, derive, field, kde, layer, partition, ribbon, spread, text
from dataset import PENGUINS, SEATTLE_WEATHER
PAPER_FILL = "#CBA45F"
PAPER_STROKE = "#745931"
D = Dist.normal(mean="mean", sd="sd")
(
chart([{"mean": 0, "sd": 1}])
.flow(partition(by=D.bin(Bin.quantiles(5)), dir="x"))
.mark(
layer(
[
ribbon(
x=D.domain(),
h=D.density(),
inset=3,
fill=PAPER_FILL,
stroke=PAPER_STROKE,
stroke_width=2,
),
circle(cx=D.median(), cy=6, r=3, fill=PAPER_STROKE),
]
)
)
).render(w=480, h=200, axes={"x": {"title": "x"}, "y": False})dataset.py
python
PENGUINS = [
{
"Species": "Adelie",
"Island": "Torgersen",
"Beak Length (mm)": 39.1,
"Beak Depth (mm)": 18.7,
"Flipper Length (mm)": 181,
"Body Mass (g)": 3750,
"Sex": "MALE",
},
{
"Species": "Adelie",
"Island": "Torgersen",
"Beak Length (mm)": 39.5,
"Beak Depth (mm)": 17.4,
"Flipper Length (mm)": 186,
"Body Mass (g)": 3800,
"Sex": "FEMALE",
},
{
"Species": "Adelie",
"Island": "Torgersen",
"Beak Length (mm)": 40.3,
"Beak Depth (mm)": 18,
"Flipper Length (mm)": 195,
"Body Mass (g)": 3250,
"Sex": "FEMALE",
},
{
"Species": "Adelie",
"Island": "Torgersen",
"Beak Length (mm)": None,
"Beak Depth (mm)": None,
"Flipper Length (mm)": None,
"Body Mass (g)": None,
"Sex": None,
},
{
"Species": "Adelie",
"Island": "Torgersen",
"Beak Length (mm)": 36.7,
"Beak Depth (mm)": 19.3,
"Flipper Length (mm)": 193,
"Body Mass (g)": 3450,
"Sex": "FEMALE",
},
# … 339 more rows
]
SEATTLE_WEATHER = [
{
"date": "2012-01-01T00:00:00.000Z",
"precipitation": 0,
"temp_max": 12.8,
"temp_min": 5,
"wind": 4.7,
"weather": "drizzle",
},
{
"date": "2012-01-02T00:00:00.000Z",
"precipitation": 10.9,
"temp_max": 10.6,
"temp_min": 2.8,
"wind": 4.5,
"weather": "rain",
},
{
"date": "2012-01-03T00:00:00.000Z",
"precipitation": 0.8,
"temp_max": 11.7,
"temp_min": 7.2,
"wind": 2.3,
"weather": "rain",
},
{
"date": "2012-01-04T00:00:00.000Z",
"precipitation": 20.3,
"temp_max": 12.2,
"temp_min": 5.6,
"wind": 4.7,
"weather": "rain",
},
{
"date": "2012-01-05T00:00:00.000Z",
"precipitation": 1.3,
"temp_max": 8.9,
"temp_min": 2.8,
"wind": 6.1,
"weather": "rain",
},
# … 1,456 more rows
]