Public
Edited
Nov 16, 2023
6 forks
39 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// load Arrow bytes from attachment, then create an Arquero table
gaia_sample = aq.fromArrow(await FileAttachment('gaia-sample.arrow').arrayBuffer())
Insert cell
// select a subset of columns and show the first 10 rows
gaia_sample
.select('ra', 'dec', 'parallax', 'phot_g_mean_mag', 'bp_rp')
.view(10)
Insert cell
Insert cell
// group data into bins and count the number of records
gaia_sample_bins = gaia_sample
.groupby({
ra: d => op.bin(d.ra, 0, 360, 2.5), // 0 = start, 360 = stop, 2.5 = step
dec: d => op.bin(d.dec, -100, 100, 2.5)
})
.count()
Insert cell
// plot the binned data as sized circles
vl.markCircle({ opacity: 0.9 })
.data(gaia_sample_bins)
.encode(
vl.x().fieldQ('ra').scale({ domain: [0, 360] }),
vl.y().fieldQ('dec'),
vl.size().fieldQ('count').scale({ range: [0, 100] })
)
.width(900)
.height(500)
.config({ axis: { domain: false, grid: false }, view: { stroke: null } })
.render()
Insert cell
Insert cell
vl.markCircle({ size: 1, blend: 'lighten' })
.data(gaia_sample)
.encode(
vl.x().fieldQ('ra').scale({ domain: [0, 360] }),
vl.y().fieldQ('dec'),
vl.color().fieldQ('bp_rp').scale({ domain: [-1, 4], scheme: 'plasma' }).legend(null)
)
.width(900)
.height(500)
.config({
axis: { domain: false, grid: false, labelColor: '#888', titleColor: '#888' },
view: { stroke: null }
})
.background('black')
.render()
Insert cell
Insert cell
vl.markCircle({ size: 1, blend: 'lighten' })
.data(gaia_sample)
.project({
type: 'mollweide',
rotate: [90, 22, -60]
})
.encode(
vl.longitude().fieldQ('ra'),
vl.latitude().fieldQ('dec'),
vl.color().fieldQ('bp_rp').scale({ domain: [-1, 4], scheme: 'plasma' }).legend(null)
)
.width(900)
.height(500)
.config({ view: { stroke: null } })
.padding(20)
.background('#000')
.render()
Insert cell
Insert cell
gaia_parallax = aq.fromArrow(await FileAttachment('gaia-parallax-sample.arrow').arrayBuffer())
Insert cell
Insert cell
gaia_parallax_bins = gaia_parallax
.filter(d => op.is_finite(d.bp_rp))
.groupby({
color: d => op.bin(d.bp_rp, -4, 7, 0.05),
mag: d => op.bin(d.phot_g_mean_mag, 2, 24, 0.1),
})
.count()
Insert cell
Insert cell
vl.markPoint({ size: 9, shape: 'square', opacity: 1, filled: true, clip: true })
.data(gaia_parallax_bins)
.encode(
vl.x().fieldQ('color')
.scale({ zero: false, domain: [-0.5, 4.5] })
.axis({ tickCount: 5, title: '← warmer BP-RP Color cooler →' }),
vl.y().fieldQ('mag')
.scale({ zero: false, domain: [21, 2] })
.axis({ title: '← dimmer Magnitude brighter →' }),
vl.color().fieldQ('count')
.scale({ type: 'sqrt', scheme: 'plasma' })
.legend(null)
)
.width(300)
.height(500)
.config({
axis: { domain: false, grid: false, labelColor: '#888', titleColor: '#888' },
view: { stroke: null }
})
.padding({ left: 5, right: 20, top: 10, bottom: 5 })
.background('black')
.render()
Insert cell
Insert cell
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