Public
Edited
Mar 25
Insert cell
Insert cell
Insert cell
Select a data source…
Type SQL, then Shift-Enter. Ctrl-space for more options.

Insert cell
nhgis0001_ds125_1990_state.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
nhgis0001_ds125_1990_state
SELECT STUSAB, unmarried_females
FROM nhgis0001_ds125_1990_state
ORDER BY unmarried_females DESC;
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.barX(nhgis0001_ds125_1990_state, {x: "unmarried_females", y: "STUSAB", sort: {y: "x", reverse: true}}),
Plot.ruleX([0])
]
})
Insert cell
Insert cell
nhgis0001_ds125_1990_state
SELECT STUSAB, AREALAND
FROM nhgis0001_ds125_1990_state
ORDER BY AREALAND DESC;
Insert cell
Plot.plot({
marks: [
Plot.barX(nhgis0001_ds125_1990_state, {x: "AREALAND", y: "STUSAB", sort: {y: "x", reverse: true}}),
Plot.ruleX([0])
]
})
Insert cell
Insert cell
nhgis0001_ds125_1990_state
SELECT
year, STUSAB, unmarried_male_female, unmarried_males, unmarried_females, other_households,
("unmarried_male_female" + "unmarried_males" + "unmarried_females" + "other_households") AS total_households
FROM
nhgis0001_ds125_1990_state;
Insert cell
Insert cell
nhgis0001_ds125_1990_state
SELECT
year, STUSAB, unmarried_male_female, unmarried_males, unmarried_females, other_households,
("unmarried_male_female" + "unmarried_males" + "unmarried_females" + "other_households") AS total_households
FROM
nhgis0001_ds125_1990_state

WHERE STUSAB = 'CA';
Insert cell
Insert cell
nhgis0001_ds125_1990_state
SELECT
year, STUSAB, unmarried_male_female, unmarried_males, unmarried_females, other_households,
("unmarried_male_female" + "unmarried_males" + "unmarried_females" + "other_households") AS total_households
FROM
nhgis0001_ds125_1990_state

WHERE STUSAB = 'SD';

Insert cell
Insert cell
california.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
california
SELECT YEAR, STUSAB, unmarried_females, total_households,
(unmarried_females / NULLIF(total_households, 0) * 100) AS unmarried_females_percentage
FROM california;
Insert cell
south_dakota.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
south_dakota
SELECT YEAR, STUSAB, unmarried_females, total_households,
(unmarried_females / NULLIF(total_households, 0) * 100) AS unmarried_females_percentage
FROM south_dakota;
Insert cell
Insert cell
chartA
SELECT YEAR, STUSAB, unmarried_females, total_households,
((unmarried_females / total_households)) AS unmarried_females_percentage
FROM chartA;
Insert cell
Plot.plot({
x: {percent:true},
marks: [
Plot.barX(chartB, {x: "unmarried_females_percentage", y: "STUSAB", sort: {y: "x", reverse: true}}),
Plot.ruleX([0])
]
})
Insert cell
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