Published
Edited
Sep 22, 2022
1 star
Insert cell
# Ex10
Insert cell
Insert cell
iris = FileAttachment("iris.csv").csv()
Insert cell
import { SummaryTable } from "@observablehq/summary-table"
Insert cell
viewof summary_data = SummaryTable(iris, {label: "Iris Data"})
Insert cell
irisTyped = iris.map(d => {
return {
sepal_length: +d.sepal_length,
sepal_width: +d.sepal_width,
petal_length: +d.petal_length,
petal_width: +d.petal_width,
species: d.species
}
});
Insert cell
viewof summary__iris_typed_data = SummaryTable(irisTyped, {label: "Iris Typed Data"})
Insert cell
Insert cell
import {vl} from '@vega/vega-lite-api-v5'
Insert cell
vl.markPoint().data(iris).encode(
vl.x().fieldQ('sepal_length').title('Sepal length (cm)'),
vl.y().fieldQ('sepal_width').title('Sepal width (cm)')
).title("Iris Dataset").render()
Insert cell
Insert cell
vl.markPoint().data(iris).encode(
vl.x().fieldQ('sepal_length').title('Sepal length (cm)'),
vl.y().fieldQ('sepal_width').title('Sepal width (cm)'),
vl.color().fieldN('species'),
vl.size().fieldQ('petal_length')
// vl.tooltip(['Name', 'Origin']) // show the Name and Origin fields in a tooltip
).title("Iris Dataset").render()
Insert cell
Insert cell
vega_embed = require("vega-embed@5")
Insert cell
plot = {
yield {
"$schema": "https://vega.github.io/schema/vega-lite/v3.4.0.json",
"title": "Iris Dataset",
"data": {"values":iris},
"config": {"view": {"width": 400, "height": 300}},
"mark": "point",
"encoding": {
"color": {"type": "nominal", "field": "species"},
"size":{"type": "quantitative", "field": "petal_length"},
"x": {"type": "quantitative", "field": "sepal_length"},
"y": {"type": "quantitative", "field": "sepal_width"}
}
}
}
Insert cell
vega_embed(plot)
Insert cell
Insert cell
SMO = FileAttachment("SMO-VOR-2015.csv").csv()
Insert cell
viewof summary_data_SMO = SummaryTable(SMO, {label: "SMO VOR 2015 dataset"})
Insert cell
vl.markPoint().data(SMO).encode(
vl.x().fieldT('ptime').title('Penetration time'),
vl.y().fieldT('alt').title('Altitude (feets)'),
vl.tooltip(["flight"])
).title("SMO VOR 2015 dataset").render()
Insert cell
Insert cell
vl.markBoxplot().data(SMO).encode(
vl.x().fieldO('month').title(null),
vl.y().fieldT('alt').title('Altitude (feets)'),
vl.color().fieldN('ops'),
vl.tooltip("flight")
).title("SMO VOR 2015 dataset").render()
Insert cell
Insert cell
vl.markBar().data(SMO).encode(
vl.x().fieldT('alt').title('Altitude (feets)'),
vl.y().count().title("Counts")
).title("SMO VOR 2015 dataset").render()
Insert cell
Insert cell
vl.markBar().data(SMO).encode(
vl.x().fieldT('alt').title('Altitude (feets)'),
vl.y().count().title("Counts"),
vl.column().fieldT('ptime').timeUnit('utcmonth')
).title("SMO VOR 2015 dataset").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