Published
Edited
May 6, 2020
4 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data1 = d3.csvParse(await FileAttachment("keywords.csv").text(), (d, i, columns) => (d3.autoType(d), d.total = d3.sum(columns, c => d[c]), d)).sort((a, b) => b["rosalind"] / b.total - a["rosalind"] / a.total)
Insert cell
series = d3.stack()
.keys(data1.columns.slice(1))
.offset(d3.stackOffsetExpand)
(data1)
.map(d => (d.forEach(v => v.key = d.key), d))
Insert cell
rects = d3.select(chart).selectAll("rect");
Insert cell
annotations = d3.select(chart).select("g#annotation");
Insert cell
x = d3.scaleLinear()
.range([margin.left, width - margin.right])
Insert cell
y = d3.scaleBand()
.domain(data1.map(d => d.name))
.range([margin.top, height - margin.bottom])
// .padding(0.1)
Insert cell
chartTitle = g => g.append("text")
.attr("font-family", "sans-serif")
.attr("font-size", 30)
.attr("x", width/2)
.attr("y", 50)
.attr("text-anchor", "middle")
.text("The Breakdown: Top Ten Topics According to LDA")
Insert cell
xAxis = g => g
.attr("transform", `translate(0,${margin.top})`)
// .call(d3.axisTop(x).ticks(width / 100, "%"))
.call(g => g.selectAll(".domain").remove())
Insert cell
yAxis = g => g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y).tickSizeOuter(0))
.call(g => g.selectAll(".domain").remove())
Insert cell
height = data1.length * 55 + margin.top + margin.bottom
Insert cell
margin = ({top: 60, right: 10, bottom: 0, left: 80})
Insert cell
Insert cell
useStopwords = true
Insert cell
customStopwords = ["shall", "thee", "thou", "le", "thy", "well", "go", "yet", "come", "enter", "hath", "first", "good", "man", "one", "say", "take", "see", "make", "might", "tis", "sir", "let", "us", "upon", "every", "may", "must", "de", "quoth", "sans"]
Insert cell
metadata = d3.csv(
"https://raw.githubusercontent.com/span728/asyoulikeit/master/index.csv"
)
Insert cell
acts = metadata.map(d => d.act);
Insert cell
files = metadata.map(d => `https://raw.githubusercontent.com/span728/asyoulikeit/master/words/${d.filename}`);
Insert cell
words = Promise.all(files.map(d=> d3.text(d)))
Insert cell
corpus = new tfidf.Corpus(
acts,
words,
useStopwords,
customStopwords,
K1,
b
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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