viewof histogramMatrix = embed({
title: "Immigration measures by country income group",
vconcat:[
{
title: "Low income countries",
repeat: {column: migrationVar},
spec:{
data: {values: migrationWide1["Low income"]},
mark: "bar",
encoding: {
x: {
bin:{"maxbins" : 12},
field:{"repeat":"column"},
type:"quantitative"
},
y: {
aggregate: "count",
field:"CO2",
type:"quantitative",
title: "Country Count"
}
}
}
},
{
title: "Lower middle income countries",
repeat: {column: migrationVar},
spec:{
data: {values: migrationWide1["Lower middle income"]},
mark: "bar",
encoding: {
x: {
bin:{"maxbins" : 12},
field:{"repeat":"column"},
type:"quantitative"
},
y: {
aggregate: "count",
field:"CO2",
type:"quantitative",
title: "Country Count"
}
}
}
},
{
title: "Upper middle income countries",
repeat: {column: migrationVar},
spec:{
data: {values: migrationWide1["Upper middle income"]},
mark: "bar",
encoding: {
x: {
bin:{"maxbins" : 12},
field:{"repeat":"column"},
type:"quantitative"
},
y: {
aggregate: "count",
field:"CO2",
type:"quantitative",
title: "Country Count"
}
}
}
},
{
title: "High income countries",
repeat: {column: migrationVar},
spec:{
data: {values: migrationWide1["High income"]},
mark: "bar",
encoding: {
x: {
bin:{"maxbins" : 12},
field:{"repeat":"column"},
type:"quantitative"
},
y: {
aggregate: "count",
field:"CO2",
type:"quantitative",
title: "Country Count"
}
}
}
},
{
title: "Unknown income countries",
// my x-axis here is probably tighter than other people's because I dropped CO2 = "TOT", which had
// huge immigration figures since it's the sum over multiple countries
repeat: {column: migrationVar},
spec:{
data: {values: migrationWide1[undefined]},
mark: "bar",
encoding: {
x: {
bin:{"maxbins" : 12},
field:{"repeat":"column"},
type:"quantitative"
},
y: {
aggregate: "count",
field:"CO2",
type:"quantitative",
title: "Country Count"
}
}
}
}
]
})