Public
Edited
Sep 11, 2023
1 star
Insert cell
Insert cell
penguins_raw = d3.csv(
"https://raw.githubusercontent.com/allisonhorst/palmerpenguins/master/inst/extdata/penguins.csv",
d3.autoType
)
Insert cell
import { aq, op } from '@uwdata/arquero';
Insert cell
penguins = aq.from(penguins_raw)
Insert cell
["All"].concat("Adelie", "Gentoo", "Chinstrap")
Insert cell
viewof pen_types = Inputs.select(["All"].concat("Adelie", "Gentoo", "Chinstrap"))
Insert cell
pen_types
Insert cell
pplot = {
let pplot;
if (pen_types == "All") {
return pplot = penguins;
} else {
return pplot = penguins.filter(aq.escape(d => op.includes(d.species, pen_types)));
}
}

Insert cell
Plot.plot({
marginLeft: 60,
color: {legend: true},
marks: [
Plot.dot(pplot, {y: "body_mass_g", x: "bill_length_mm", fill: "species"})
]
})
Insert cell
foo = {
return (pen_types === "All")
? penguins // If pen_types is "All", no filtering is applied
: penguins.filter(aq.escape(d => op.includes(d.species, pen_types)));
}
Insert cell
["All"].concat(penguins.dedupe("island").array("island"))
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more