Public
Edited
Dec 18, 2023
7 forks
17 stars
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
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
tswift_pivoted.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
features = ["acousticness","danceability","energy", "speechiness", "instrumentalness", "liveness", "valence"]
Insert cell
Insert cell
albums = [...new Set(songs.map(d => d.album_name))].sort()
Insert cell
facet_features = ['valence','danceability','energy']
Insert cell
Insert cell
song_features_subset = song_features.filter(d => facet_features.includes(d.feature))
Insert cell
Insert cell
correlations = d3.cross(features, features).map(([a, b]) => ({
a,
b,
correlation: corr(Plot.valueof(songs, a), Plot.valueof(songs, b))
}))
Insert cell
Insert cell
Insert cell
Select a data source…
Type SQL, then Shift-Enter. Ctrl-space for more options.

Insert cell
songs
SELECT
key_name
,count(*)/263::double as songs
,count(case when mode_name='major' then track_name end)/263::double as major_songs
,count(case when mode_name='minor' then track_name end)/263::double as minor_songs
FROM songs
WHERE key_mode != 'NA'
GROUP BY 1
ORDER BY 1
Insert cell
Insert cell
songs
SELECT
track_name
,album_name
,round(liveness,2) as liveness
,round(valence,2) as valence
,round(energy,2) as energy
,round(acousticness,2) as acousticness
FROM songs
WHERE
valence >= ${sliders.valence}
and energy >= ${sliders.energy}
and acousticness >= ${sliders.acousticness}
Insert cell
Insert cell
import {corr} from "@observablehq/plot-correlation-heatmap"
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
<style>

@import url('https://fonts.googleapis.com/css?family=Yomogi&display=swap');
@import url('https://fonts.googleapis.com/css?family=Roboto&display=swap');
@import url('https://fonts.googleapis.com/css?family=Roboto+Mono&display=swap');

div > h1, div> h2, div>h3 {
font-family:Yomogi!important;
}

body {
font-family:Roboto;
}

h1, h2 {
text-transform:uppercase;
}

h2 {
margin-bottom:10px;
}

code {
background:#D4D7F5!important;
color:#401487!important;
padding:2px 4px!important;
border-radius:3px;
}
p, h1, h2 {
max-width:100%;
}

ul {
max-width:90%;
}

li {
margin-bottom:2px;
}

label {
font-weight:bold!important;
}
</style>
Insert cell
viewof select = Inputs.select(["A", "B"], {label: "Select one"})
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