Public
Edited
Sep 27, 2023
Insert cell
Insert cell
Insert cell

function funcPlot(func, scope, N=100) {return Plot.plot({
width:400, height:400,
inset:10,
marks: [
Plot.frame(),
Plot.line(Array.apply(null, {length: N+1}).map((d,i)=>{return i}),{
x:d=>scope[0]+((scope[1]-scope[0])*d/N),
y:d=>func(scope[0]+((scope[1]-scope[0])*d/N)),
}),
Plot.axisX({ y: 0 }),
Plot.axisY({ x: 0 }),
Plot.ruleX([0]),
Plot.ruleY([0])
]
})}
Insert cell
p6 = funcPlot((x)=>Math.pow(2,x),[-3,3]);
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