Plot.plot({
width: 800,
height: 600,
x: {
type: "log",
domain: [100, 100_000],
label: "liquid flow (barrels/day)"
},
y: { type: "log", domain: [0.5, 50], label: "velocity (ft/s)" },
marks: [
Plot.gridX(
d3
.range(100, 1_000, 20)
.concat(d3.range(1_000, 10_000, 200))
.concat(d3.range(10_000, 100_000, 2_000))
.concat(100_000),
{
strokeOpacity: (d) =>
Math.log10(d) % 1
? Math.log10(d * 5) % 1 && Math.log10(d * 2) % 1
? 0.2
: 0.5
: 1,
strokeWidth: 0.5
}
),
Plot.gridY(
d3
.range(0.5, 1, 0.05)
.concat(d3.range(1, 10, 0.2))
.concat(d3.range(10, 50, 1))
.concat(50),
{
strokeOpacity: (d) =>
Math.log10(d) % 1 && Math.log10(d * 2) % 1
? Math.log10(d * 5) % 1
? 0.2
: 0.5
: 1,
strokeWidth: 0.5
}
),
Plot.ruleY([3, 14], { stroke: "red" }),
Plot.link(references, {
x1: ({ value }) => (Y(100, value) > 0.5 ? 100 : Yr(0.5, value)),
y1: ({ value }) => Math.max(Y(100, value), 0.5),
x2: ({ value }) => (Y(100_000, value) < 50 ? 100_000 : Yr(50, value)),
y2: ({ value }) => Math.min(Y(100_000, value), 50)
}),
Plot.text([3, 14], {
y: (d) => d,
text: ["Minimum", "Maximum"],
stroke: "var(--plot-background)",
fill: "red",
lineAnchor: "bottom",
frameAnchor: "left",
dx: 50,
dy: -3
}),
Plot.text(references, {
text: "ref",
x: ({ value }) => x(value),
y: ({ value }) => Y(x(value), value),
rotate: -48.1,
textAnchor: "start",
fontWeight: "bold",
dx: -5,
dy: -5,
fill: "currentColor",
stroke: "var(--plot-background)"
})
]
})