hispanicScatterplot = {
return addTooltips(
Plot.plot({
marginTop: 30,
marginBottom: 50,
marginLeft: 50,
marginRight: 30,
title:
"Comparing percentage of Hispanic FTIC students to percentage point increase from 6-year to 8-year graduation rates.",
caption: caption(
"Data Source: [NCES IPEDS - 2014 Cohort](https://nces.ed.gov/ipeds/use-the-data)"
),
width: Math.max(width, 600),
height: 600,
color: {
legend: false,
scheme: "Cool",
opacity: 1,
reverse: true,
style: { fontSize: "1em" }
},
x: {
percent: false,
grid: true,
label: "Percentage of Hispanic Students",
tickFormat: d3.format("0.0%"),
domain: [0.1, 1]
},
y: {
grid: false,
label: "Percentage Point Increase",
domain: [0, 7.2]
},
style: {
font: "bold 11px sans-serif"
},
color: {
domain: [
"Public Independent",
"TAMUS",
"TSUS",
"TTUS",
"TWU",
"UHS",
"UNTS",
"UTS",
"Statewide"
], //, "Professional"],
range: [
"#6a51a3",
"#500000",
"#8e7449",
"#CC0000",
"#E3D353",
"#888b8d",
"#00853E",
"#F47920",
"#2166AC"
],
legend: false
},
marks: [
Plot.dot(noHBCU, {
x: "hispanic_total",
y: "ChangePP",
stroke: "System",
fill: "System",
r: "HispanicC",
title: (d) =>
`${d.University}\n6-Year Rate: ${d3.format("0.0%")(
d.Bach6
)}\n8-Year Rate: ${d3.format("0.0%")(
d.Bach8
)}\nPercentage Point Change: ${d3.format(",")(
d.ChangePP
)}\nPercentage of Hispanic Students: ${d3.format("0.1%")(
d.hispanic_total
)}`
// tip: true
}),
Plot.linearRegressionY(noHBCU, {
x: "hispanic_total",
y: "ChangePP",
ci: 0.89,
stroke: "#600000"
}),
// Plot.text(noHBCU, {
// filter: (d) => d.University === "PVAMU",
// x: "hispanic_total",
// y: "ChangePP",
// fontSize: 12,
// text: (d) => d.University,
// // dx: 8,
// dy: 15
// }),
Plot.text(noHBCU, {
// filter: (d) => d.NonWhiteP >= 0.94,
filter: (d) =>
d.University === "TAMIU" ||
d.University === "TX Southern" ||
d.University === "UTEP" ||
d.University === "UH Downtown" ||
d.University === "UH" ||
d.University === "UNT Dallas" ||
d.University === "TAMUK" ||
d.University === "TWU" ||
d.University === "UTRGV",
x: "hispanic_total",
y: "ChangePP",
fontSize: 12,
fill: "System",
text: (d) => d.University,
// dx: 8,
dy: -15
// dy: (d) => 10 + Math.random() * 10 // Add random vertical offset
// textAnchor: "start",
// align: "left"
// filter: (d, i, data) => {
// const currentLabel = data[i].University;
// const previousLabels = data
// .slice(0, i)
// .map((item) => item.University);
// return !previousLabels.includes(currentLabel);
// }
})
]
})
);
}