Public
Edited
Feb 24
Insert cell
Insert cell
{
const rasterWidth = 135;
const rasterHeight = 231;
const ratio = rasterWidth / rasterHeight;
const rasterPlot = Plot.plot({
color: {
scheme: 'BuGn',
legend: true,
},
width: 300,
aspectRatio: 1,
marks: [
Plot.raster(data, {
width: 135,
height: 231,
x1: 93.835,
x2: 108.82,
y1: 34.053,
y2: 8.411999999999999,
interpolate: "none",
}),
]
});

// if ("querySelectorAll" in rasterPlot) {
// const rasters = rasterPlot.querySelectorAll(
// 'g[aria-label="raster"]>image'
// );
// rasters.forEach((r) => {
// r.setAttribute("preserveAspectRatio", "xMidYMid meet");
// });
// }
return rasterPlot;
}
Insert cell
data = FileAttachment("New Text Document.TXT").csv({array: true}).then(rows => rows.flat().map((x) => (x === "" ? NaN : parseFloat(x))))
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