import pandas as pd
import matplotlib.pyplot as plt
women_degrees = pd.read_csv('percent-bachelors-degrees-women-usa.csv')
major_cats = ['Biology', 'Computer Science', 'Engineering', 'Math and Statistics']
# plt.plot(women_degrees['Year'], women_degrees['Biology'])
# plt.show()
# plt.plot(women_degrees['Year'], women_degrees['Biology'], c='blue', label='Women')
# plt.plot(women_degrees['Year'], 100 - women_degrees['Biology'], c='green', label='Men')
# plt.legend(loc='upper right')
# plt.title('Percentage of Biology Degrees Awarded By Gender')
# plt.show()
# fig, ax = plt.subplots()
# ax.plot(women_degrees['Year'], women_degrees['Biology'], label='Women')
# ax.plot(women_degrees['Year'], 100 - women_degrees['Biology'], label='Men')
# #图像的刻度、标注等部分作不显示设置
# ax.tick_params(bottom="off", top="off", left="off", right="off")
# ax.set_title('Percentage of Biology Degrees Awarded By Gender')
# ax.legend(loc="upper right")
#
# plt.show()
# fig, ax = plt.subplots()
# ax.plot(women_degrees['Year'], women_degrees['Biology'], c='blue', label='Women')
# ax.plot(women_degrees['Year'], 100 - women_degrees['Biology'], c='green', label='Men')
# ax.tick_params(bottom="off", top="off", left="off", right="off")
#
# for key, spine in ax.spines.items():
# spine.set_visible(False)
# ax.legend(loc='upper right')
# plt.show()
# fig = plt.figure(figsize=(12, 12))
#
# for sp in range(0, 4):
# ax = fig.add_subplot(2, 2, sp + 1)
# ax.plot(women_degrees['Year'], women_degrees[major_cats[sp]], c='blue', label='Women')
# ax.plot(women_degrees['Year'], 100 - women_degrees[major_cats[sp]], c='green', label='Men')
#
# # Calling pyplot.legend() here will add the legend to the last subplot that was created.
# plt.legend(loc='upper right')
# plt.show()
# major_cats = ['Biology', 'Computer Science', 'Engineering', 'Math and Statistics']
# fig = plt.figure(figsize=(12, 12))
#
# for sp in range(0, 4):
# ax = fig.add_subplot(2, 2, sp + 1)
# ax.plot(women_degrees['Year'], women_degrees[major_cats[sp]], c='blue', label='Women')
# ax.plot(women_degrees['Year'], 100 - women_degrees[major_cats[sp]], c='green', label='Men')
# for key, spine in ax.spines.items():
# spine.set_visible(False)
# ax.set_xlim(1968, 2011)
# ax.set_ylim(0, 100)
# ax.set_title(major_cats[sp])
# ax.tick_params(bottom="off", top="off", left="off", right="off")
#
# # Calling pyplot.legend() here will add the legend to the last subplot that was created.
# plt.legend(loc='upper right')
# plt.show()
# Setting Line Width
cb_dark_blue = (0 / 255, 107 / 255, 164 / 255)
cb_orange = (255 / 255, 128 / 255, 14 / 255)
#
# fig = plt.figure(figsize=(12, 12))
#
# for sp in range(0, 4):
# ax = fig.add_subplot(2, 2, sp + 1)
# # Set the line width when specifying how each line should look.
# ax.plot(women_degrees['Year'], women_degrees[major_cats[sp]], c=cb_dark_blue, label='Women', linewidth=10)
# ax.plot(women_degrees['Year'], 100 - women_degrees[major_cats[sp]], c=cb_orange, label='Men', linewidth=10)
# for key, spine in ax.spines.items():
# spine.set_visible(False)
# ax.set_xlim(1968, 2011)
# ax.set_ylim(0, 100)
# ax.set_title(major_cats[sp])
# ax.tick_params(bottom="off", top="off", left="off", right="off")
#
# plt.legend(loc='upper right')
# plt.show()
stem_cats = ['Engineering', 'Computer Science', 'Psychology', 'Biology', 'Physical Sciences', 'Math and Statistics']
# fig = plt.figure(figsize=(18, 3))
#
# 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()
# fig = plt.figure(figsize=(18, 3))
#
# 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()
# fig = plt.figure(figsize=(18, 3))
#
# 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")
#
# if sp == 0:
# ax.text(2005, 87, 'Men') #在指定位置添加文字
# ax.text(2002, 8, 'Women')
# elif sp == 5:
# ax.text(2005, 62, 'Men')
# ax.text(2001, 35, 'Women')
# plt.show()
没有合适的资源?快使用搜索试试~ 我知道了~
Python数据分析与机器学习-Matplotlib
共11个文件
py:7个
csv:4个
需积分: 10 37 下载量 38 浏览量
2017-12-27
21:55:28
上传
评论
收藏 39KB ZIP 举报
温馨提示
Python数据分析与机器学习-Matplotlib,Python数据分析与机器学习-Matplotlib
资源推荐
资源详情
资源评论
收起资源包目录
chapter04.zip (11个子文件)
chapter04
fandango_scores.csv 15KB
matplotlibTest05.py 3KB
matplotlibTest02.py 3KB
matplotlibTest03.py 3KB
unrate.csv 13KB
matplotlibTest06.py 6KB
matplotlibTest04.py 2KB
matplotlibTest01.py 937B
train.csv 60KB
matplotlibTest07.py 310B
percent-bachelors-degrees-women-usa.csv 6KB
共 11 条
- 1
资源评论
未来,值得期待
- 粉丝: 218
- 资源: 73
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功