surveyData = {
return {
favouriteTest: [
{ test: "t-test", votes: 47, reason: "Only one I understand" },
{ test: "Chi-square", votes: 31, reason: "Fun to say" },
{ test: "ANOVA", votes: 22, reason: "Sounds important" },
{ test: "Correlation", votes: 38, reason: "Everything correlates with everything" },
{ test: "Regression", votes: 15, reason: "Makes me feel like a data scientist" },
{ test: "Mann-Whitney U", votes: 8, reason: "Sounds like a secret agent" }
],
favouritePValue: [
{ p: "p = .049", votes: 62, label: "Just scraped in" },
{ p: "p < .001", votes: 45, label: "The dream" },
{ p: "p = .051", votes: 28, label: "Pain" },
{ p: "p = .05", votes: 18, label: "Exactly on the line" },
{ p: "p = .69", votes: 12, label: "Nice" },
{ p: "p = 1.00", votes: 3, label: "Did I break R?" }
],
tools: [
{ tool: "R", pct: 34, feeling: "Terrifying but powerful" },
{ tool: "Excel", pct: 28, feeling: "It has graphs, right?" },
{ tool: "Jamovi", pct: 19, feeling: "R with training wheels" },
{ tool: "Calculator", pct: 11, feeling: "If it was good enough for Fisher..." },
{ tool: "Gut feeling", pct: 8, feeling: "p < vibes" }
],
weeklyMood: [
{ week: "Wk 1", mood: 8.2, label: "This will be fine" },
{ week: "Wk 3", mood: 6.5, label: "What is a z-score" },
{ week: "Wk 5", mood: 4.1, label: "I chose the wrong degree" },
{ week: "Wk 7", mood: 3.2, label: "Why are there Greek letters" },
{ week: "Wk 9", mood: 5.8, label: "Wait I think I get it" },
{ week: "Wk 11", mood: 7.4, label: "Actually this is cool" },
{ week: "Wk 13", mood: 4.0, label: "Exam panic" }
]
};
}Plot.plot({
height: 300,
marginLeft: 130,
marginRight: 120,
style: { fontSize: "12px", fontFamily: "Source Sans 3, sans-serif" },
x: { label: "Votes", grid: true },
y: { label: null },
color: { scheme: "warm" },
marks: [
Plot.barX(surveyData.favouriteTest.sort((a, b) => b.votes - a.votes), {
y: "test",
x: "votes",
fill: "test",
sort: { y: "-x" },
tip: true,
title: d => `${d.test}: ${d.votes} votes — "${d.reason}"`
}),
Plot.text(surveyData.favouriteTest, {
y: "test",
x: d => d.votes + 1,
text: d => `"${d.reason}"`,
textAnchor: "start",
fontSize: 10,
fontStyle: "italic",
fill: "#666"
})
]
})Plot.plot({
height: 300,
marginLeft: 80,
marginRight: 100,
style: { fontSize: "12px", fontFamily: "Source Sans 3, sans-serif" },
x: { label: "Votes", grid: true },
y: { label: null },
marks: [
Plot.barX(surveyData.favouritePValue.sort((a, b) => b.votes - a.votes), {
y: "p",
x: "votes",
fill: d => d.p === "p = .049" ? "#9B1B30" : d.p === "p < .001" ? "#28a745" : d.p === "p = .051" ? "#E78021" : "#6c757d",
sort: { y: "-x" },
tip: true,
title: d => `${d.p}: ${d.votes} votes — "${d.label}"`
}),
Plot.text(surveyData.favouritePValue, {
y: "p",
x: d => d.votes + 1,
text: "label",
textAnchor: "start",
fontSize: 10,
fontStyle: "italic",
fill: "#666"
})
]
})Plot.plot({
height: 320,
marginLeft: 50,
marginBottom: 50,
style: { fontSize: "12px", fontFamily: "Source Sans 3, sans-serif" },
x: { label: null, domain: surveyData.weeklyMood.map(d => d.week) },
y: { label: "Mood (0-10)", domain: [0, 10], grid: true },
marks: [
Plot.areaY(surveyData.weeklyMood, {
x: "week",
y: "mood",
fill: "#9B1B30",
fillOpacity: 0.15,
curve: "catmull-rom"
}),
Plot.lineY(surveyData.weeklyMood, {
x: "week",
y: "mood",
stroke: "#9B1B30",
strokeWidth: 3,
curve: "catmull-rom"
}),
Plot.dot(surveyData.weeklyMood, {
x: "week",
y: "mood",
fill: "#9B1B30",
r: 6,
tip: true,
title: d => `${d.week}: ${d.mood}/10 — "${d.label}"`
}),
Plot.text(surveyData.weeklyMood, {
x: "week",
y: d => d.mood + 0.6,
text: "label",
fontSize: 9,
fontStyle: "italic",
fill: "#666"
}),
Plot.ruleY([5], { stroke: "#999", strokeDasharray: "4,4" })
]
})Plot.plot({
height: 320,
marginLeft: 100,
marginRight: 120,
style: { fontSize: "12px", fontFamily: "Source Sans 3, sans-serif" },
x: { label: "% of students", grid: true, domain: [0, 45] },
y: { label: null },
marks: [
Plot.barX(surveyData.tools.sort((a, b) => b.pct - a.pct), {
y: "tool",
x: "pct",
fill: d => d.tool === "R" ? "#9B1B30" : d.tool === "Jamovi" ? "#61589C" : d.tool === "Excel" ? "#28a745" : "#6c757d",
sort: { y: "-x" },
tip: true,
title: d => `${d.tool}: ${d.pct}% — "${d.feeling}"`
}),
Plot.text(surveyData.tools, {
y: "tool",
x: d => d.pct + 1,
text: d => `"${d.feeling}"`,
textAnchor: "start",
fontSize: 10,
fontStyle: "italic",
fill: "#666"
})
]
})