# import pandas as pd
# import matplotlib.pyplot as plt
# name='djz,sc,rc'.split(',')
# df = pd.read_csv('study.csv',delimiter=',',names=name,skiprows=1).drop_duplicates().dropna()
# plt.style.use('seaborn-dark')
# plt.rcParams['font.family']='simsun'
# plt.figure(figsize=(13,6))
# ax1 = plt.subplot(111)
# plt.grid()
# ax2 = ax1.twinx()
# ax1.plot(df.djz,df.sc,marker='v',linestyle='-.',c='skyblue',label='观看时长/小时')
# ax2.plot(df.djz,df.rc,marker='o',linestyle='--',c='y',label='观看人次')
# plt.title('学期视频观看趋势(按教学周)分析')
# ax1.set_xlabel('教学周')
# ax1.set_ylabel('观看时长/小时')
# ax2.set_ylabel('观看人次')
# ax1.legend(loc='upper left')
# ax2.legend(loc='upper right')
# plt.show()
第二题
from matplotlib import pyplot as plt
import pandas as pd
name1='sj,sc,rs'.split(',')
df1=pd.read_csv('study.csv',sep=',',skiprows=1,names=name1)
plt.style.use('seaborn')
plt.rcParams['font.family']='simhei'
plt.figure(figsize=(13,6))
ax1=plt.subplot(111)
ax2=plt.twiny()
ax1.plot(df1.sc,df1.sj,marker='o',c='lightgreen',linestyle='-',label='观看时长/小时')
ax2.plot(df1.rs,df1.sj,marker='o',c='skyblue',linestyle='--',label='观看人次')
plt.title('学期视频观看趋势(按教学周)分析')
ax1.set_xlabel('观看时长/小时')
ax2.set_xlabel('观看人次')
ax1.set_ylabel('教学周')
ax1.legend(loc='upper left')
ax2.legend(loc='upper right')
plt.grid(False)
plt.show()