Back to Article
利用violinplot函数绘制小提琴图
Download Notebook
In [1]:
import pandas as pd
url ='https://raw.githubusercontent.com/tidyverse/datascience-box/refs/heads/main/course-materials/lab-instructions/lab-02/data/plastic-waste.csv'
df = pd.read_csv(url)
df
code entity continent year gdp_per_cap plastic_waste_per_cap mismanaged_plastic_waste_per_cap mismanaged_plastic_waste coastal_pop total_pop
0 AFG Afghanistan Asia 2010 1614.255001 NaN NaN NaN NaN 31411743.0
1 ALB Albania Europe 2010 9927.181841 0.069 0.032 29705.0 2530533.0 3204284.0
2 DZA Algeria Africa 2010 12870.602699 0.144 0.086 520555.0 16556580.0 35468208.0
3 ASM American Samoa Oceania 2010 NaN NaN NaN NaN NaN 68420.0
4 AND Andorra Europe 2010 NaN NaN NaN NaN NaN 84864.0
... ... ... ... ... ... ... ... ... ... ...
235 VNM Vietnam Asia 2010 4408.168612 0.103 0.090 1833819.0 55858245.0 87848445.0
236 ESH Western Sahara Africa 2010 NaN NaN NaN NaN NaN 530500.0
237 YEM Yemen Asia 2010 4478.743599 0.103 0.077 169181.0 6048920.0 NaN
238 ZMB Zambia Africa 2010 3279.277161 NaN NaN NaN NaN 13088570.0
239 ZWE Zimbabwe Africa 2010 1474.877128 NaN NaN NaN NaN 12571454.0

240 rows × 10 columns

In [2]:
%pip install ggplot
Note: you may need to restart the kernel to use updated packages.
Collecting ggplot
  Downloading ggplot-0.11.5-py2.py3-none-any.whl.metadata (2.9 kB)
Collecting brewer2mpl (from ggplot)
  Downloading brewer2mpl-1.4.1-py2.py3-none-any.whl.metadata (3.7 kB)
Requirement already satisfied: cycler in c:\users\shuos\anaconda3\lib\site-packages (from ggplot) (0.11.0)
Requirement already satisfied: matplotlib in c:\users\shuos\anaconda3\lib\site-packages (from ggplot) (3.8.4)
Requirement already satisfied: numpy in c:\users\shuos\anaconda3\lib\site-packages (from ggplot) (1.26.4)
Requirement already satisfied: pandas in c:\users\shuos\anaconda3\lib\site-packages (from ggplot) (2.2.2)
Requirement already satisfied: patsy>=0.4 in c:\users\shuos\anaconda3\lib\site-packages (from ggplot) (0.5.6)
Requirement already satisfied: scipy in c:\users\shuos\anaconda3\lib\site-packages (from ggplot) (1.13.1)
Requirement already satisfied: six in c:\users\shuos\anaconda3\lib\site-packages (from ggplot) (1.16.0)
Requirement already satisfied: statsmodels in c:\users\shuos\anaconda3\lib\site-packages (from ggplot) (0.14.2)
Requirement already satisfied: contourpy>=1.0.1 in c:\users\shuos\anaconda3\lib\site-packages (from matplotlib->ggplot) (1.2.0)
Requirement already satisfied: fonttools>=4.22.0 in c:\users\shuos\anaconda3\lib\site-packages (from matplotlib->ggplot) (4.51.0)
Requirement already satisfied: kiwisolver>=1.3.1 in c:\users\shuos\anaconda3\lib\site-packages (from matplotlib->ggplot) (1.4.4)
Requirement already satisfied: packaging>=20.0 in c:\users\shuos\anaconda3\lib\site-packages (from matplotlib->ggplot) (23.2)
Requirement already satisfied: pillow>=8 in c:\users\shuos\anaconda3\lib\site-packages (from matplotlib->ggplot) (10.3.0)
Requirement already satisfied: pyparsing>=2.3.1 in c:\users\shuos\anaconda3\lib\site-packages (from matplotlib->ggplot) (3.0.9)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\shuos\anaconda3\lib\site-packages (from matplotlib->ggplot) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in c:\users\shuos\anaconda3\lib\site-packages (from pandas->ggplot) (2024.1)
Requirement already satisfied: tzdata>=2022.7 in c:\users\shuos\anaconda3\lib\site-packages (from pandas->ggplot) (2023.3)
Downloading ggplot-0.11.5-py2.py3-none-any.whl (2.2 MB)
   ---------------------------------------- 0.0/2.2 MB ? eta -:--:--
   ---------------------------------------- 0.0/2.2 MB ? eta -:--:--
   ---------------------------------------- 0.0/2.2 MB ? eta -:--:--
   ---------------------------------------- 0.0/2.2 MB ? eta -:--:--
   ---------------------------------------- 0.0/2.2 MB ? eta -:--:--
   ---------------------------------------- 0.0/2.2 MB ? eta -:--:--
    --------------------------------------- 0.0/2.2 MB 146.3 kB/s eta 0:00:15
    --------------------------------------- 0.0/2.2 MB 146.3 kB/s eta 0:00:15
    --------------------------------------- 0.0/2.2 MB 146.3 kB/s eta 0:00:15
    --------------------------------------- 0.0/2.2 MB 146.3 kB/s eta 0:00:15
    --------------------------------------- 0.0/2.2 MB 93.7 kB/s eta 0:00:24
    --------------------------------------- 0.0/2.2 MB 93.7 kB/s eta 0:00:24
   - -------------------------------------- 0.1/2.2 MB 121.3 kB/s eta 0:00:18
   - -------------------------------------- 0.1/2.2 MB 121.3 kB/s eta 0:00:18
   - -------------------------------------- 0.1/2.2 MB 121.3 kB/s eta 0:00:18
   - -------------------------------------- 0.1/2.2 MB 121.3 kB/s eta 0:00:18
   - -------------------------------------- 0.1/2.2 MB 103.4 kB/s eta 0:00:21
   - -------------------------------------- 0.1/2.2 MB 128.0 kB/s eta 0:00:17
   -- ------------------------------------- 0.1/2.2 MB 142.4 kB/s eta 0:00:15
   -- ------------------------------------- 0.1/2.2 MB 150.2 kB/s eta 0:00:14
   -- ------------------------------------- 0.1/2.2 MB 170.4 kB/s eta 0:00:13
   -- ------------------------------------- 0.2/2.2 MB 169.9 kB/s eta 0:00:13
   --- ------------------------------------ 0.2/2.2 MB 184.1 kB/s eta 0:00:12
   --- ------------------------------------ 0.2/2.2 MB 184.1 kB/s eta 0:00:12
   --- ------------------------------------ 0.2/2.2 MB 193.4 kB/s eta 0:00:11
   --- ------------------------------------ 0.2/2.2 MB 191.7 kB/s eta 0:00:11
   ---- ----------------------------------- 0.2/2.2 MB 205.4 kB/s eta 0:00:10
   ---- ----------------------------------- 0.3/2.2 MB 224.6 kB/s eta 0:00:09
   ---- ----------------------------------- 0.3/2.2 MB 224.6 kB/s eta 0:00:09
   ----- ---------------------------------- 0.3/2.2 MB 233.5 kB/s eta 0:00:09
   ----- ---------------------------------- 0.3/2.2 MB 233.5 kB/s eta 0:00:09
   ----- ---------------------------------- 0.3/2.2 MB 233.5 kB/s eta 0:00:09
   ----- ---------------------------------- 0.3/2.2 MB 213.2 kB/s eta 0:00:10
   ----- ---------------------------------- 0.3/2.2 MB 213.2 kB/s eta 0:00:10
   ----- ---------------------------------- 0.3/2.2 MB 213.2 kB/s eta 0:00:10
   ----- ---------------------------------- 0.3/2.2 MB 213.2 kB/s eta 0:00:10
   ----- ---------------------------------- 0.3/2.2 MB 213.2 kB/s eta 0:00:10
   ----- ---------------------------------- 0.3/2.2 MB 213.2 kB/s eta 0:00:10
   ----- ---------------------------------- 0.3/2.2 MB 213.2 kB/s eta 0:00:10
   ----- ---------------------------------- 0.3/2.2 MB 213.2 kB/s eta 0:00:10
   ----- ---------------------------------- 0.3/2.2 MB 213.2 kB/s eta 0:00:10
   ----- ---------------------------------- 0.3/2.2 MB 213.2 kB/s eta 0:00:10
   ----- ---------------------------------- 0.3/2.2 MB 213.2 kB/s eta 0:00:10
   ----- ---------------------------------- 0.3/2.2 MB 213.2 kB/s eta 0:00:10
   ----- ---------------------------------- 0.3/2.2 MB 213.2 kB/s eta 0:00:10
   ----- ---------------------------------- 0.3/2.2 MB 155.8 kB/s eta 0:00:13
   ----- ---------------------------------- 0.3/2.2 MB 157.3 kB/s eta 0:00:13
   ----- ---------------------------------- 0.3/2.2 MB 157.3 kB/s eta 0:00:13
   ------ --------------------------------- 0.3/2.2 MB 157.7 kB/s eta 0:00:12
   ------ --------------------------------- 0.4/2.2 MB 168.7 kB/s eta 0:00:11
   ------- -------------------------------- 0.4/2.2 MB 177.9 kB/s eta 0:00:11
   ------- -------------------------------- 0.4/2.2 MB 185.9 kB/s eta 0:00:10
   ------- -------------------------------- 0.4/2.2 MB 185.9 kB/s eta 0:00:10
   ------- -------------------------------- 0.4/2.2 MB 184.7 kB/s eta 0:00:10
   ------- -------------------------------- 0.4/2.2 MB 184.7 kB/s eta 0:00:10
   -------- ------------------------------- 0.5/2.2 MB 183.0 kB/s eta 0:00:10
   -------- ------------------------------- 0.5/2.2 MB 183.0 kB/s eta 0:00:10
   -------- ------------------------------- 0.5/2.2 MB 184.3 kB/s eta 0:00:10
   -------- ------------------------------- 0.5/2.2 MB 184.3 kB/s eta 0:00:10
   -------- ------------------------------- 0.5/2.2 MB 184.3 kB/s eta 0:00:10
   -------- ------------------------------- 0.5/2.2 MB 184.3 kB/s eta 0:00:10
   -------- ------------------------------- 0.5/2.2 MB 184.3 kB/s eta 0:00:10
   -------- ------------------------------- 0.5/2.2 MB 184.3 kB/s eta 0:00:10
   -------- ------------------------------- 0.5/2.2 MB 184.3 kB/s eta 0:00:10
   -------- ------------------------------- 0.5/2.2 MB 168.4 kB/s eta 0:00:11
   --------- ------------------------------ 0.5/2.2 MB 172.8 kB/s eta 0:00:10
   --------- ------------------------------ 0.5/2.2 MB 178.1 kB/s eta 0:00:10
   --------- ------------------------------ 0.5/2.2 MB 178.1 kB/s eta 0:00:10
   ---------- ----------------------------- 0.6/2.2 MB 181.9 kB/s eta 0:00:10
   ---------- ----------------------------- 0.6/2.2 MB 191.1 kB/s eta 0:00:09
   ----------- ---------------------------- 0.6/2.2 MB 196.3 kB/s eta 0:00:09
   ----------- ---------------------------- 0.6/2.2 MB 204.2 kB/s eta 0:00:08
   ------------ --------------------------- 0.7/2.2 MB 208.7 kB/s eta 0:00:08
   ------------ --------------------------- 0.7/2.2 MB 214.2 kB/s eta 0:00:08
   ------------ --------------------------- 0.7/2.2 MB 214.2 kB/s eta 0:00:08
   ------------ --------------------------- 0.7/2.2 MB 217.4 kB/s eta 0:00:07
   ------------ --------------------------- 0.7/2.2 MB 217.4 kB/s eta 0:00:07
   ------------ --------------------------- 0.7/2.2 MB 217.4 kB/s eta 0:00:07
   ------------ --------------------------- 0.7/2.2 MB 217.4 kB/s eta 0:00:07
   ------------- -------------------------- 0.7/2.2 MB 206.6 kB/s eta 0:00:08
   ------------- -------------------------- 0.7/2.2 MB 206.6 kB/s eta 0:00:08
   ------------- -------------------------- 0.8/2.2 MB 210.8 kB/s eta 0:00:07
   -------------- ------------------------- 0.8/2.2 MB 212.8 kB/s eta 0:00:07
   -------------- ------------------------- 0.8/2.2 MB 218.5 kB/s eta 0:00:07
   -------------- ------------------------- 0.8/2.2 MB 218.5 kB/s eta 0:00:07
   --------------- ------------------------ 0.9/2.2 MB 229.2 kB/s eta 0:00:06
   ---------------- ----------------------- 0.9/2.2 MB 229.1 kB/s eta 0:00:06
   ---------------- ----------------------- 0.9/2.2 MB 229.1 kB/s eta 0:00:06
   ---------------- ----------------------- 0.9/2.2 MB 229.1 kB/s eta 0:00:06
   ----------------- ---------------------- 1.0/2.2 MB 238.1 kB/s eta 0:00:06
   ----------------- ---------------------- 1.0/2.2 MB 238.1 kB/s eta 0:00:06
   ----------------- ---------------------- 1.0/2.2 MB 241.1 kB/s eta 0:00:06
   ------------------ --------------------- 1.0/2.2 MB 245.8 kB/s eta 0:00:05
   ------------------- -------------------- 1.1/2.2 MB 255.3 kB/s eta 0:00:05
   ------------------- -------------------- 1.1/2.2 MB 255.3 kB/s eta 0:00:05
   ------------------- -------------------- 1.1/2.2 MB 255.3 kB/s eta 0:00:05
   ------------------- -------------------- 1.1/2.2 MB 255.3 kB/s eta 0:00:05
   -------------------- ------------------- 1.1/2.2 MB 250.4 kB/s eta 0:00:05
   -------------------- ------------------- 1.1/2.2 MB 253.3 kB/s eta 0:00:05
   -------------------- ------------------- 1.1/2.2 MB 253.0 kB/s eta 0:00:05
   -------------------- ------------------- 1.1/2.2 MB 253.0 kB/s eta 0:00:05
   --------------------- ------------------ 1.2/2.2 MB 259.0 kB/s eta 0:00:04
   ---------------------- ----------------- 1.2/2.2 MB 263.0 kB/s eta 0:00:04
   ---------------------- ----------------- 1.2/2.2 MB 265.7 kB/s eta 0:00:04
   ---------------------- ----------------- 1.2/2.2 MB 265.7 kB/s eta 0:00:04
   ----------------------- ---------------- 1.3/2.2 MB 270.4 kB/s eta 0:00:04
   ----------------------- ---------------- 1.3/2.2 MB 270.8 kB/s eta 0:00:04
   ----------------------- ---------------- 1.3/2.2 MB 270.8 kB/s eta 0:00:04
   ------------------------ --------------- 1.4/2.2 MB 276.9 kB/s eta 0:00:04
   ------------------------- -------------- 1.4/2.2 MB 279.7 kB/s eta 0:00:03
   ------------------------- -------------- 1.4/2.2 MB 287.4 kB/s eta 0:00:03
   -------------------------- ------------- 1.5/2.2 MB 288.8 kB/s eta 0:00:03
   -------------------------- ------------- 1.5/2.2 MB 291.3 kB/s eta 0:00:03
   --------------------------- ------------ 1.5/2.2 MB 295.3 kB/s eta 0:00:03
   --------------------------- ------------ 1.5/2.2 MB 297.7 kB/s eta 0:00:03
   --------------------------- ------------ 1.5/2.2 MB 297.0 kB/s eta 0:00:03
   ---------------------------- ----------- 1.6/2.2 MB 296.5 kB/s eta 0:00:03
   ---------------------------- ----------- 1.6/2.2 MB 296.5 kB/s eta 0:00:03
   ---------------------------- ----------- 1.6/2.2 MB 296.9 kB/s eta 0:00:03
   ---------------------------- ----------- 1.6/2.2 MB 296.9 kB/s eta 0:00:03
   ---------------------------- ----------- 1.6/2.2 MB 296.9 kB/s eta 0:00:03
   ---------------------------- ----------- 1.6/2.2 MB 296.9 kB/s eta 0:00:03
   ---------------------------- ----------- 1.6/2.2 MB 296.9 kB/s eta 0:00:03
   ---------------------------- ----------- 1.6/2.2 MB 296.9 kB/s eta 0:00:03
   ---------------------------- ----------- 1.6/2.2 MB 284.5 kB/s eta 0:00:03
   ---------------------------- ----------- 1.6/2.2 MB 284.5 kB/s eta 0:00:03
   ---------------------------- ----------- 1.6/2.2 MB 284.5 kB/s eta 0:00:03
   ---------------------------- ----------- 1.6/2.2 MB 284.5 kB/s eta 0:00:03
   ----------------------------- ---------- 1.6/2.2 MB 279.9 kB/s eta 0:00:03
   ----------------------------- ---------- 1.6/2.2 MB 281.1 kB/s eta 0:00:02
   ------------------------------ --------- 1.7/2.2 MB 286.9 kB/s eta 0:00:02
   ------------------------------ --------- 1.7/2.2 MB 286.9 kB/s eta 0:00:02
   ------------------------------ --------- 1.7/2.2 MB 284.8 kB/s eta 0:00:02
   ------------------------------ --------- 1.7/2.2 MB 284.8 kB/s eta 0:00:02
   ------------------------------- -------- 1.7/2.2 MB 283.8 kB/s eta 0:00:02
   ------------------------------- -------- 1.8/2.2 MB 284.2 kB/s eta 0:00:02
   ------------------------------- -------- 1.8/2.2 MB 283.7 kB/s eta 0:00:02
   -------------------------------- ------- 1.8/2.2 MB 285.6 kB/s eta 0:00:02
   -------------------------------- ------- 1.8/2.2 MB 285.6 kB/s eta 0:00:02
   -------------------------------- ------- 1.8/2.2 MB 285.6 kB/s eta 0:00:02
   -------------------------------- ------- 1.8/2.2 MB 285.6 kB/s eta 0:00:02
   --------------------------------- ------ 1.8/2.2 MB 283.8 kB/s eta 0:00:02
   --------------------------------- ------ 1.8/2.2 MB 285.4 kB/s eta 0:00:02
   --------------------------------- ------ 1.9/2.2 MB 285.8 kB/s eta 0:00:02
   --------------------------------- ------ 1.9/2.2 MB 285.8 kB/s eta 0:00:02
   --------------------------------- ------ 1.9/2.2 MB 285.8 kB/s eta 0:00:02
   --------------------------------- ------ 1.9/2.2 MB 285.8 kB/s eta 0:00:02
   --------------------------------- ------ 1.9/2.2 MB 285.8 kB/s eta 0:00:02
   --------------------------------- ------ 1.9/2.2 MB 285.8 kB/s eta 0:00:02
   --------------------------------- ------ 1.9/2.2 MB 285.8 kB/s eta 0:00:02
   --------------------------------- ------ 1.9/2.2 MB 285.8 kB/s eta 0:00:02
   --------------------------------- ------ 1.9/2.2 MB 285.8 kB/s eta 0:00:02
   --------------------------------- ------ 1.9/2.2 MB 285.8 kB/s eta 0:00:02
   ---------------------------------- ----- 1.9/2.2 MB 270.1 kB/s eta 0:00:02
   ---------------------------------- ----- 1.9/2.2 MB 270.1 kB/s eta 0:00:02
   ---------------------------------- ----- 1.9/2.2 MB 270.1 kB/s eta 0:00:02
   ---------------------------------- ----- 1.9/2.2 MB 270.1 kB/s eta 0:00:02
   ---------------------------------- ----- 1.9/2.2 MB 270.1 kB/s eta 0:00:02
   ---------------------------------- ----- 1.9/2.2 MB 262.7 kB/s eta 0:00:02
   ---------------------------------- ----- 1.9/2.2 MB 264.4 kB/s eta 0:00:02
   ----------------------------------- ---- 1.9/2.2 MB 266.9 kB/s eta 0:00:01
   ----------------------------------- ---- 1.9/2.2 MB 266.9 kB/s eta 0:00:01
   ----------------------------------- ---- 1.9/2.2 MB 266.9 kB/s eta 0:00:01
   ----------------------------------- ---- 2.0/2.2 MB 265.8 kB/s eta 0:00:01
   ------------------------------------ --- 2.0/2.2 MB 267.1 kB/s eta 0:00:01
   ------------------------------------ --- 2.0/2.2 MB 266.2 kB/s eta 0:00:01
   ------------------------------------ --- 2.0/2.2 MB 266.2 kB/s eta 0:00:01
   ------------------------------------ --- 2.0/2.2 MB 266.2 kB/s eta 0:00:01
   ------------------------------------ --- 2.0/2.2 MB 266.2 kB/s eta 0:00:01
   ------------------------------------ --- 2.0/2.2 MB 264.0 kB/s eta 0:00:01
   ------------------------------------ --- 2.0/2.2 MB 264.0 kB/s eta 0:00:01
   ------------------------------------- -- 2.0/2.2 MB 262.4 kB/s eta 0:00:01
   ------------------------------------- -- 2.0/2.2 MB 262.4 kB/s eta 0:00:01
   ------------------------------------- -- 2.0/2.2 MB 262.4 kB/s eta 0:00:01
   ------------------------------------- -- 2.0/2.2 MB 262.4 kB/s eta 0:00:01
   ------------------------------------- -- 2.1/2.2 MB 258.0 kB/s eta 0:00:01
   ------------------------------------- -- 2.1/2.2 MB 259.6 kB/s eta 0:00:01
   ------------------------------------- -- 2.1/2.2 MB 258.8 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 260.4 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 260.4 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 260.4 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 260.4 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 260.4 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 260.4 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 260.4 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 260.4 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 260.4 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 260.4 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 260.4 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 260.4 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 260.4 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 260.4 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 243.6 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 243.6 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 243.6 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 243.6 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 243.6 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 243.6 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 243.6 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 243.6 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 243.6 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 243.6 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 243.6 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 243.6 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 243.6 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 243.6 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 226.1 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 226.1 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 226.1 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 226.1 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 226.1 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 226.1 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 226.1 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 226.1 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 226.1 kB/s eta 0:00:01
   -------------------------------------- - 2.1/2.2 MB 226.1 kB/s eta 0:00:01
   ---------------------------------------  2.2/2.2 MB 217.4 kB/s eta 0:00:01
   ---------------------------------------  2.2/2.2 MB 219.1 kB/s eta 0:00:01
   ---------------------------------------- 2.2/2.2 MB 220.0 kB/s eta 0:00:00
Downloading brewer2mpl-1.4.1-py2.py3-none-any.whl (24 kB)
Installing collected packages: brewer2mpl, ggplot
Successfully installed brewer2mpl-1.4.1 ggplot-0.11.5
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))': /simple/ggplot/
In [3]:
import pandas as pd
from lets_plot import *

LetsPlot.setup_html()
In [4]:
(
    ggplot(df, aes("continent", "plastic_waste_per_cap")) +
    geom_histogram()
)
In [5]:
(
    ggplot(df, aes("continent", "plastic_waste_per_cap"))
    + geom_boxplot()
)
In [6]:
import seaborn as sns
import matplotlib.pyplot as plt

# 利用violinplot函数绘制小提琴图
sns.violinplot(x=df["continent"], y=df["plastic_waste_per_cap"])

plt.show()

In [7]:
(
    ggplot(df, aes("plastic_waste_per_cap", "mismanaged_plastic_waste_per_cap")) +
  geom_point()
)
In [8]:
(
    ggplot(df, aes("plastic_waste_per_cap", "mismanaged_plastic_waste_per_cap", colour="continent")) +
  geom_point()
)
In [9]:
(
ggplot(df, aes(x="total_pop", y="plastic_waste_per_cap", colour="continent")) +
  geom_point() +
  xlim(0, 150000000) +
  ylim(0, 0.8)
)
In [10]:
(
ggplot(df, aes(x="coastal_pop", y="plastic_waste_per_cap", colour="continent")) +
  geom_point() +
  xlim(0, 50000000) +
  ylim(0, 0.8)
)