Public
Edited
Jan 5, 2024
Insert cell
Insert cell
Insert cell
Plot.plot({
y: {grid: true},
color: {legend: true},
marks: [
Plot.areaY(data1, {x: "x", y: "y", stroke: "z", fill: "z"}),
]
})
Insert cell
Insert cell
Plot.plot({
y: {grid: true},
color: {legend: true},
marks: [
Plot.areaY(data1, {x: "x", y: (d) => Math.max(0, d.y), stroke: "z", fill: "z", fillOpacity: 0.5}),
Plot.areaY(data1, {x: "x", y: (d) => Math.min(-0, d.y), stroke: "z", fill: "z", fillOpacity: 0.5}),
]
})
Insert cell
Insert cell
Plot.plot({
y: {grid: true},
color: {legend: true},
marks: [
Plot.areaY(data3, {x: "x", y: "y", stroke: "z", fill: "z", fillOpacity: 0.5}),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
Plot.plot({
y: {grid: true},
color: {legend: true},
marks: [
Plot.areaY(data3, {x: "x", y: (d) => Math.max(0, d.y), stroke: "z", fill: "z", fillOpacity: 0.5}),

// This needs to be e.g. -0.00001 instead of just -0.0 to remove the bottom zig-zag lines.
Plot.areaY(data3, {x: "x", y: (d) => Math.min(-0.0, d.y), stroke: "z", fill: "z", fillOpacity: 0.5}),

Plot.ruleY([0])
]
})
Insert cell
Insert cell
data1 = FileAttachment("data1.csv").csv({typed: true})
Insert cell
data3 = FileAttachment("data3-fixed@1.csv").csv({typed: true})
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