python - Matplotlib:每条线具有不同组的折线图
问题描述
例如这张表:
list_1=[['2010','20-30',0.2],
['2010','31-40',0.35],
['2010','41-50',0.47,],
['2010','51-60',0.21,],
['2011','20-30',0.23,],
['2011','31-40',0.42,],
['2011','41-50',0.55,],
['2011','51-60',0.19,],
['2012','20-30',0.36,],
['2012','31-40',0.24,],
['2012','41-50',0.71,],
['2012','51-60',0.12,]]
labels=['Year','Age_group','Order_Rate']
df=pd.DataFrame(list_1,columns=labels)
df
输出:
Year Age_group Order_Rate
0 2010 20-30 0.20
1 2010 31-40 0.35
2 2010 41-50 0.47
3 2010 51-60 0.21
4 2011 20-30 0.23
5 2011 31-40 0.42
6 2011 41-50 0.55
7 2011 51-60 0.19
8 2012 20-30 0.36
9 2012 31-40 0.24
10 2012 41-50 0.71
11 2012 51-60 0.12
我需要制作 x_axis= Year, y_axis= Order_Rate 和此 Age_Group 的每种颜色趋势线的折线图
解决方案
推荐阅读
- ruby - `gem install` 忽略了 $GEM_HOME
- python-3.x - python中的舍入函数
- radio - USSD 通信的无线电资源使用情况
- python - 需要从不同的列表中挑选单个元素并将它们存储在字典中
- node.js - 如何使用 Jsonwebtoken NPM 包验证 Azure AD 颁发的 JWT 令牌?
- sql - SQL:使用前一行的值填充当前行
- mysql - 是否可以在时间戳上对 Mysql 表进行索引
- python - 输入两个单独的列表并输出一个字典列表
- android - 如何从可移动 sd 卡路径中获取所有文件路径和名称?
- c++ - 如何检查用户输入是否超过一个字母并在 C++ 中正确显示