Public
Edited
Nov 11, 2022
15 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// create a client from the attached Parquet files
client = DuckDBClient.of({
gaia: FileAttachment("gaia-sample@6.parquet"),
parallax: FileAttachment("parallax@2.parquet")
})
Insert cell
client.describeColumns({ table: "gaia" })
Insert cell
client.describeColumns({ table: "parallax" })
Insert cell
client
SELECT count()::INT as cnt
FROM gaia
Insert cell
size = sizeTable[0].cnt
Insert cell
client
-- select a subset of columns
SELECT ra, dec, parallax, phot_g_mean_mag, bp_rp
FROM gaia
Insert cell
Insert cell
client
WITH gaia_binned AS (
SELECT
floor(ra / 2.5) * 2.5 AS ra,
floor(dec / 2.5) * 2.5 AS dec
FROM gaia
)
SELECT ra, dec, count()::INT as count
FROM gaia_binned
GROUP BY ra, dec
Insert cell
// plot the binned data as sized circles
vl.markCircle({ opacity: 0.9 })
.data(gaia_bins)
.encode(
vl.x().fieldQ('ra').scale({ domain: [0, 360] }),
vl.y().fieldQ('dec').scale({ domain: [-100, 100] }),
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
client
SELECT ra, dec, bp_rp
FROM gaia
LIMIT 50000
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
Insert cell
client
WITH parallax_binned AS (
SELECT
floor(bp_rp / 0.05) * 0.05 AS color,
floor(phot_g_mean_mag / 0.1) * 0.1 AS mag
FROM parallax
)
SELECT color, mag, count()::INT as count
FROM parallax_binned
GROUP BY color, mag
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

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