Skip to content

Instantly share code, notes, and snippets.

(
Boxplot()
.add_xaxis(
x_axis#
)
.add_yaxis(
"Population 2007",
y_axis_pop2007
)
.add_yaxis(
x_axis = gapminder.sort_values("continent").continent.unique().tolist()
y_axis_pop2007 = []
y_axis_pop1952 = []
for x in x_axis:
pop07 = (
gapminder
.query("continent == @x")
.query("year == 2007")
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Awesome-pyecharts</title>
<script type="text/javascript" src="https://assets.pyecharts.org/assets/echarts.min.js"></script>
</head>
<body>
<div id="0bd2f4c4114a460880b0ab7bd31c5491" class="chart-container" style="width:1024px; height:600px;"></div>
(
Bar(
opts.InitOpts(
#theme = ThemeType.DARK,
width = "1024px",
height = "600px"
)
)
.add_xaxis(gap_by_continent.continent.tolist())
.add_yaxis(
gap_by_continent = (
gapminder
.groupby("continent")
.agg(
pop_mean = ('pop', 'mean'),
pop_sd = ('pop', 'std'),
pop_median = ('pop', 'median'),
le_mean = ('lifeExp', 'mean'),
le_sd = ('lifeExp', 'std')
)
from pyecharts.charts import Bar
from pyecharts.charts import Boxplot
from pyecharts import options as opts
import pandas as pd
from gapminder import gapminder
sns.set_palette(sns.color_palette(met_brewer.palettes.met_brew("Navajo", 5), as_cmap = True))
chart = sns.boxplot(
data = gapminder.query('year == 2007').assign(popInMio = lambda x: x["pop"] / 1000000),
y = "gdpPercap", x = "continent",
hue = "continent"
)
chart.set_ylabel("GDP per Capita")
chart.set_xlabel("Continent")
chart.get_legend().set_title("Continent")
sns.set_palette(sns.color_palette(met_brewer.palettes.met_brew("Navajo", 5), as_cmap = True))
chart = sns.scatterplot(
data = gapminder.query('year == 2007').assign(popInMio = lambda x: x["pop"] / 1000000),
x = "gdpPercap", y = "lifeExp",
hue = "continent", size = "popInMio",
sizes=(50, 750)
)
chart.set_xlabel("GDP per Capita")
chart.set_ylabel("Life Expectancy")
sns.set_palette(sns.color_palette(met_brewer.palettes.met_brew(name = "Cross", n = 100, brew_type = "continuous"), as_cmap = True))
chart = sns.scatterplot(
data = gapminder.query('year == 2007').assign(popInMio = lambda x: x["pop"] / 1000000),
x = "gdpPercap", y = "lifeExp",
hue = "popInMio", size = "popInMio",
sizes=(50, 750)
)
chart.set_xlabel("GDP per Capita")
import seaborn as sns
from gapminder import gapminder
import met_brewer.palettes
sns.set_theme(style="whitegrid")