#範例4-12:自行建立DataFrame資料集,然後用express印出四位學生的三科成績 import pandas as pd import plotly.express as px #數據資料表,採用三個串列List(coulumn=course,record_name=name, record_data = score) df = pd.DataFrame({ '姓名':['john','mary','peter','jolin'], '國文':[75,90,65,95], '英文':[85,90,55,65], '數學':[95,90,60,90] }) #用plotly.express畫圖 fig = px.line(title='全班同學的國文英文數學分數') fig.add_scatter(x=df["姓名"], y=df["國文"],name='國文',showlegend=True) fig.add_scatter(x=df["姓名"], y=df["英文"],name='英文',showlegend=True) fig.add_scatter(x=df["姓名"], y=df["數學"],name='數學',showlegend=True) #fig.show() fig.write_html('exp4-12.html',auto_open=True)