This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chart = ( | |
alt.Chart( | |
gapminder | |
.query('gdpPercap < 60000') | |
.assign(popInMio = lambda x: x["pop"] / 1000000) | |
) | |
.mark_boxplot() | |
.encode( | |
alt.X( | |
"continent", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chart = ( | |
alt.Chart( | |
gapminder | |
.query('gdpPercap < 60000') | |
.assign(popInMio = lambda x: x["pop"] / 1000000) | |
) | |
.mark_boxplot() | |
.encode( | |
alt.X( | |
"continent", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
color = alt.Color( | |
"continent:N", | |
legend = alt.Legend(title = "Continent"), | |
scale = alt.Scale(range = met_brewer.palettes.met_brew("Navajo", 5)) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chart = ( | |
alt.Chart( | |
gapminder | |
.query('year == 2007') | |
.assign(popInMio = lambda x: x["pop"] / 1000000) | |
) | |
.mark_circle(size = 160) | |
.encode( | |
alt.X( | |
"gdpPercap:Q", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import libraries | |
import altair as alt | |
from gapminder import gapminder | |
import met_brewer.palettes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
) + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot + | |
geom_point( | |
aes(gdpPercap, lifeExp, size = pop/1000000, color = continent) | |
) + | |
scale_color_manual(values = met.brewer("Navajo", 5)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot + geom_point( | |
aes(gdpPercap, lifeExp, color = pop/1000000, size = pop/1000000) | |
) + | |
scale_color_gradientn(colors = met.brewer("Cross", n = 500, type="continuous")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot + geom_point( | |
aes(gdpPercap, lifeExp, size = pop/1000000, color = pop/1000000) | |
) + | |
scale_color_gradientn(colors = c("#003049", "#D62828", "#F77F00", "#FCBF49", "#EAE2B7")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot + geom_point( | |
aes(gdpPercap, lifeExp, size = pop/1000000, color = pop/1000000) | |
) |