首页 > 其他 > 详细

可视化matplotlib2

时间:2018-10-19 20:12:27      阅读:217      评论:0      收藏:0      [点我收藏+]
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import pandas as pd
import matplotlib.pyplot as plt
women_degrees = pd.read_csv(‘percent-bachelors-degrees-women-usa.csv‘)
plt.plot(women_degrees[‘Year‘], women_degrees[‘Biology‘])
plt.show()


stem_cats = [‘Engineering‘, ‘Computer Science‘, ‘Psychology‘, ‘Biology‘, ‘Physical Sciences‘, ‘Math and Statistics‘]
fig = plt.figure(figsize=(18, 3))
#各种颜色
cb_dark_blue = (0/255, 107/255, 164/255)
cb_orange = (255/255, 128/255, 14/255)

for sp in range(0,6):
    ax = fig.add_subplot(1,6,sp+1)

    ax.plot(women_degrees[‘Year‘], women_degrees[stem_cats[sp]], c=cb_dark_blue, label=‘Women‘, linewidth=3)
    ax.plot(women_degrees[‘Year‘], 100-women_degrees[stem_cats[sp]], c=cb_orange, label=‘Men‘, linewidth=3)
    for key,spine in ax.spines.items():
        spine.set_visible(False)
    ax.set_xlim(1968, 2011)
    ax.set_ylim(0,100)
    ax.set_title(stem_cats[sp])
    ax.tick_params(bottom="off", top="off", left="off", right="off")

plt.legend(loc=‘upper right‘)
plt.show()

 

可视化matplotlib2

原文:https://www.cnblogs.com/lifengwu/p/9818416.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!