Public
Edited
Apr 28, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
fishing = [{river: "San Juan", species: "rainbow", lengthInches: 18.2},
{river: "San Juan", species: "brown", lengthInches: 14.1},
{river: "San Juan", species: "brown", lengthInches: 21.5},
{river: "Rio Grande", species: "brown", lengthInches: 9.0},
{river: "Rio Grande", species: "brown", lengthInches: 12.5},
{river: "Rio Grande", species: "cutthroat", lengthInches: 10.6},
{river: "Rio Grande", species: "brown", lengthInches: 14.5},
{river: "Rio Chama", species: "rainbow", lengthInches: 8.5},
{river: "Rio Chama", species: "rainbow", lengthInches: 11.5}]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//Group the data by species, then get an array of objects for rainbow trout.

Insert cell
Insert cell
Insert cell
// Use Array.filter to get a subset only for rainbow trout in fishing:

Insert cell
Insert cell
// Find the mean trout length by river:

Insert cell
Insert cell
// Get just the mean trout size for the San Juan River:

Insert cell
Insert cell
Insert cell
Insert cell
// Load the us_imports.csv file (attached in this notebook):
us_imports = FileAttachment("us_imports.csv").csv({typed: true})
Insert cell
Insert cell
Insert cell
Insert cell
// Return an array of all values in the 'value' property of us_imports, log transformed

Insert cell
Insert cell
Insert cell
// Create a new array, usLogValue, containing all existing properties and ADDING the log transformed value as a property named logValue:

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.barX(
us_imports,
Plot.groupY(
{ x: "sum" },
{
x: "value",
y: "Sector",
sort: { y: "x", reverse: true }
}
)
)
],
x: { tickFormat: ".1s" },
width: 900
})
Insert cell
import { showMe } from "@observablehq/show-me"
Insert cell
import { addTooltips } from "@mkfreeman/plot-tooltip"
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