Skip to content

Instantly share code, notes, and snippets.

chart = (
alt.Chart(
gapminder
.query('gdpPercap < 60000')
.assign(popInMio = lambda x: x["pop"] / 1000000)
)
.mark_boxplot()
.encode(
alt.X(
"continent",
chart = (
alt.Chart(
gapminder
.query('gdpPercap < 60000')
.assign(popInMio = lambda x: x["pop"] / 1000000)
)
.mark_boxplot()
.encode(
alt.X(
"continent",
color = alt.Color(
"continent:N",
legend = alt.Legend(title = "Continent"),
scale = alt.Scale(range = met_brewer.palettes.met_brew("Navajo", 5))
)
chart = (
alt.Chart(
gapminder
.query('year == 2007')
.assign(popInMio = lambda x: x["pop"] / 1000000)
)
.mark_circle(size = 160)
.encode(
alt.X(
"gdpPercap:Q",
# import libraries
import altair as alt
from gapminder import gapminder
import met_brewer.palettes
gapminder %>%
filter(gdpPercap < 60000) %>%
ggplot(aes(continent, gdpPercap, color = year, fill = continent)) +
geom_boxplot() +
theme_minimal() +
labs(
x = "Continent",
y = "GDP per Capita",
color = "Year"
) +
@scheithauer
scheithauer / cp.R
Created March 17, 2022 10:32
cp 07
plot +
geom_point(
aes(gdpPercap, lifeExp, size = pop/1000000, color = continent)
) +
scale_color_manual(values = met.brewer("Navajo", 5))
@scheithauer
scheithauer / cp.R
Created March 17, 2022 10:30
cp 06
plot + geom_point(
aes(gdpPercap, lifeExp, color = pop/1000000, size = pop/1000000)
) +
scale_color_gradientn(colors = met.brewer("Cross", n = 500, type="continuous"))
@scheithauer
scheithauer / cp.R
Created March 17, 2022 10:28
CP 05
plot + geom_point(
aes(gdpPercap, lifeExp, size = pop/1000000, color = pop/1000000)
) +
scale_color_gradientn(colors = c("#003049", "#D62828", "#F77F00", "#FCBF49", "#EAE2B7"))
plot + geom_point(
aes(gdpPercap, lifeExp, size = pop/1000000, color = pop/1000000)
)