Public
Edited
Mar 5, 2023
Insert cell
Insert cell
function changeColor (chart, color, fontsize) {
d3
.select(chart)
.select("[aria-label=x-axis]")
.selectAll("text")
.each(function (d) {
// d is the tick's value (in this case, a number)
d3.select(this)
.attr("fill", color)
.attr("font-size", fontsize)
.attr("font-family", "IBM Plex Sans");
})

d3
.select(chart)
.select("[aria-label=y-axis]")
.selectAll("text")
.each(function (d) {
// d is the tick's value (in this case, a number)
d3.select(this)
.attr("fill", color)
.attr("font-size", fontsize)
.attr("font-family", "IBM Plex Sans");
})

d3
.select(chart)
.select("[aria-label=x-axis]")
.selectAll("line")
.each(function (d) {
// d is the tick's value (in this case, a number)
d3.select(this)
.attr("stroke", color)
})

d3
.select(chart)
.select("[aria-label=y-axis]")
.selectAll("line")
.each(function (d) {
// d is the tick's value (in this case, a number)
d3.select(this)
.attr("stroke", color)
})

d3.select(chart)
.selectAll("text")
.each(function(d) {
d3.select(this)
.attr("font-family", "IBM Plex Sans");
})

return chart
}
Insert cell
changeColor(pChart, 'black', 24)
Insert cell
pChart = Plot.plot({
inset: 8,
width: 1200,
height: 500,
marginRight: 50, // space to the left of the chart
marginBottom: 70, // space below the chart
marginTop: 50,
marginLeft: 100,
color: {
legend: true,
},
x: {
label: "Gravitational force (GDP, 2019) →",
tickFormat: "~e",
type: "log",
ticks: 5, },
y: {
label: "↑ Gravitational force (Population, 2019)",
type: "log",
tickFormat: "~e",
ticks: 5,
},
marks: [
Plot.dot(data, {x: "total_flights", y: "p_total_flights_2019", stroke: "#96B478", r: 7})
]
})
Insert cell
data = FileAttachment("predicted-flights.csv").csv({typed: true})
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more