Published
Edited
Apr 5, 2020
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
bees = d3.range(4)
Insert cell
flowers = d3.range(7)
Insert cell
relationships = {
var apple = []
for (var i = 0; i < bees.length; i++) {
for (var j = 0; j < flowers.length; j++) {
if(Math.random()>.8) apple.push([bees[i], flowers[j]])
}
}
return apple
}
Insert cell
width = 800
Insert cell
height =300
Insert cell
beeeee = {
var svg = d3.select(DOM.svg(width, height))
.attr("width", width+"px")
.attr("height", height+"px");
const x = d3.scaleLinear().range([20,width-20]).domain(d3.extent(bees))
const y = d3.scaleLinear().range([20,width-20]).domain(d3.extent(flowers))
svg.selectAll("line.connections").data(relationships).enter().append("line")
.attr("class","connections")
.attr("x1",d=>x(d[0]))
.attr("y1",height/3)
.attr("x2",d=>y(d[1]))
.attr("y2",height*2/3)
.style("stroke","black")
.style("stroke-width","1px")
svg.selectAll("circle.bees").data(bees).enter().append("circle")
.attr("class","bees")
.attr("cx",d=>x(d))
.attr("cy",height/3)
.attr("r", 10)
.style("fill", "yellow")
svg.selectAll("circle.flowers").data(flowers).enter().append("circle")
.attr("class","flowers")
.attr("cx",d=>y(d))
.attr("cy",height*2/3)
.attr("r", 10)
.style("fill", "blue")

yield svg.node();
}
Insert cell
Insert cell
image2 = FileAttachment("generalist.png").image()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
md` *Place Heading of the Below and above interactions* `
Insert cell
Insert cell
Insert cell
Insert cell
md`# Adjacenct Matrix. (Explain how to understand the matrix in this scenario)`
Insert cell
Insert cell
Insert cell
Insert cell
md` Below is a representation of the adjacency matrix. We can try graphing this soon. In the explanation, mention what the row and the column would mean `
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