Public
Edited
Dec 19
Insert cell
Insert cell
Insert cell
container={Plot.plot({
facet: {
data: olympians,
y: "sport",
marginLeft: 50
},
marks: [
Plot.frame({stroke: "#aaa", strokeWidth: 0.5}),
Plot.dot(olympians, {x: "weight", y: "sex", fill: "sex", r: 3})
],
height: 800,
marginTop: 0,
marginLeft: 100,
width,
x: {inset: 10, grid: true, label: "weight (kg) →"},
y: {axis: null, inset: 2},
color: {legend: true}
})}
Insert cell
Insert cell
Plot.plot({
x: {
axis: null,
domain: stateage.ages
},
y: {
grid: true,
tickFormat: "s"
},
color: {
domain: stateage.ages,
scheme: "spectral",
legend: true
},
fx: {
domain: d3.groupSort(stateage, v => d3.sum(v, d => -d.population), d => d.state).slice(0, 6),
label: null,
tickSize: 6
},
facet: {
data: stateage,
x: "state"
},
marks: [
Plot.barY(stateage, {x: "age", y: "population", fill: "age", title: "age"}),
Plot.ruleY([0])
],
width
})
Insert cell
import {stateage} from "@observablehq/plot-bar"
Insert cell
import {Plot} from "@mkfreeman/plot-tooltip"
Insert cell
Insert cell
Insert cell
viewof k = Inputs.range([1, 20], {label: "Window size", step: 1, value: 1})
Insert cell
viewof reducer = Inputs.select(["mean", "median", "min", "max", "sum", "ratio"], {label: "Reducer"})
Insert cell
smooth = Plot.plot({
marks: [
Plot.ruleY([0]),
Plot.lineY(aapl, Plot.windowY({x: "Date", y: "Close", reduce: reducer, k: k}))
]
})
Insert cell
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.ruleY([1]),
Plot.line(stocks,
Plot.normalizeY({x: "Date", y: "Close", stroke: "Symbol", title: "Symbol"})),
],
y: {
type: "log",
grid: true,
label: "↑ Change in price (%)",
tickFormat: (f => x => f((x - 1) * 100))(d3.format("+d"))
},
})
Insert cell
import {stocks} from "@observablehq/plot-map"
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.barY(alphabet, {x: "letter", y: "frequency",
title: b=> `${b.letter}: ${(b.frequency*100).toFixed(2)}%`,
sort: {x: "y", reverse: true}}),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
alphabet
Insert cell
Insert cell
//selectedAthletes = olympians.filter(d=>d.nationality === "USA")
Insert cell
Plot.plot({
marks: [
Plot.rectY(selectedAthletes, Plot.binX({y: "count"}, {x: "weight", fill: "sex"})),
Plot.ruleY([0])
],
color: {
legend: true
},
x: {
domain: [0, 200]
}
})
Insert cell
Insert cell
viewof selectedAthletes = Inputs.select(d3.group(olympians, d=>d.sport),{label:"Sport: "})
Insert cell
Plot.plot({
marks: [
Plot.rectY(selectedAthletes, Plot.binX({y: "count"}, {x: "weight", fill: "sex"})),
Plot.ruleY([0])
],
color: {
legend: true
},
x: {
domain: [0, 200]
}
})
Insert cell
viewof minFrequency = Inputs.range([0, .15], {label: "Min Frequency", step: .01, value: 0})
Insert cell
alphaFiltered = alphabet.filter(d=>d.frequency >=minFrequency)
Insert cell
Plot.plot({
marks: [
Plot.barY(alphaFiltered, {x: "letter", y: "frequency" }),
Plot.ruleY([0])
],
x: {domain: d3.sort(alphabet.map(d=>d.letter))}
})
Insert cell
Insert cell
viewof minFreq2 = Inputs.range([0, .15], {label: "Min Frequency", step: .01, value: 1})
Insert cell
Plot.plot({
marks: [
Plot.ruleY([0, minFreq2]),
Plot.barY(alphabet, {x: "letter", y:"frequency",
fill: d=>d.frequency >=minFreq2 ? "steelblue" : "lightgray"})
]
})
Insert cell
viewof cylinders = Inputs.radio([3,4,5,6,8], {label: "Cylinders", value: 3})
Insert cell
viwofcylinders = Plot.plot({
marks: [
Plot.dot(cars, {x:"power (hp)", y: "economy (mpg)", title: "name",
fill: d=>d.cylinders === cylinders? "steelblue" : "lightgray",
fillOpacity: d=>d.cylinders === cylinders? 0.8 : 1,
r:d=>d.cylinders === cylinders ? 4:2
})
],
height: 600,
width
})
Insert cell
import {carMakes} from "@observablehq/lesson-2-data-representation"
Insert cell
carMakes
Insert cell
viewof xDimension = Inputs.select(["economy (mpg)", "displacement (cc)", "power (hp), weight (lb)", "0-60 mph(s)"], {label: "X Axis"})
Insert cell
viewof yDimension = Inputs.select(["make", "cylinders"], {label: "Y Axis"})
Insert cell
Plot.plot({
marks: [
Plot.dot(carMakes, {x:xDimension, y:yDimension, fill: "cylinders", title:"name",
sort:{y:"x", reverse: true, limit: 10}})
],
color:{
type: "ordinal",
legend: true
},
marginLeft: 100,
width
})
Insert cell
Insert cell
viewof duration = Inputs.range([1, 30], {label: "# of Years", step: 1, value: 30})
Insert cell
viewof purchasePrice = Inputs.range([100000, 1000000], {label: "Purchase PRice", step: 50000, value: 650000})
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more