Public
Edited
Mar 24, 2023
Insert cell
Insert cell
import {vl} from "@vega/vega-lite-api"

Insert cell
vegalite = require("@observablehq/vega-lite@0.2")
Insert cell
import {fromColumns, printTable} from '@uwdata/data-utilities'
Insert cell
data = FileAttachment("cleaned_nst.csv").csv()
Insert cell
vl.markBoxplot()
.title("Distribution of birth, death and migration rates of all the states in the US")
.data(data)
.encode(
vl.x().fieldN('Distributions'),
vl.y().fieldQ('Values'),
vl.color().fieldN('Distributions')
)

.width(600)
.render()
Insert cell
data1 = FileAttachment("nst-est2019-alldata.csv").csv()
Insert cell
vl.markBar()
.title("Histogram1 : Distribution of the death rate of all the states in the US")
.data(data1)
.encode(
vl.x().fieldQ('RDEATH2019')
.bin({'maxbins':10}),
vl.y().aggregate('count'),
)

.width(700)
.render()
Insert cell
vl.markBar()
.title("Histogram2 : Distribution of the death rate of all the states in the US")
.data(data1)
.encode(
vl.x().fieldQ('RDEATH2019')
.bin({'maxbins':30}),
vl.y().aggregate('count'),
)

.width(700)
.render()
Insert cell
vl.markLine()
.title("eCDF : Distribution of the death rate fof all the states in the US")
.data(data1)
.transform({
"sort": [{"field": "RDEATH2019"}],
"window": [{"op": "count", "field": "count", "as": "Cumulative Count"}],
"frame": [null, 0]
})
.encode(
vl.x().fieldQ('RDEATH2019'),
// .bin(true),
vl.y().fieldQ('Cumulative Count'),
// vl.color().fieldN('STNAME')
// .legend(null),
// vl.tooltip().fieldN('STNAME')
)

.width(700)
.render()
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