绘图要求
准备工作
import numpy as np
import pandas as pd
import plotly.graph_objects as go
from plotly.subplots import make_subplots #绘多幅图片
第一题
data = pd.read_csv('weatherdata2020-05-14.csv',header=None)
data.head()
这段代码里包含了双y轴的操作
data_shanghai = data[(data[3]=='上海')&(data[2]=='闵行')]
layout = go.Layout(width=1000,height=500,yaxis1 = dict(title = '$温度(^oC)$'),yaxis2=dict(title = '湿度(%)',anchor='x', overlaying='y', side='right'),
xaxis = dict(title = '时间'))
data1 = go.Scatter(x=data_shanghai[1],y=data_shanghai[4],mode = 'lines+markers',name = '温度')
data2 = go.Scatter(x=data_shanghai[1],y=data_shanghai[5],mode = 'lines+markers',yaxis='y2',name = '湿度')
data = [data1,data2]
fig = go.Figure(data = data,layout=layout)
fig.show()
第二题
plotly多幅绘图操作
fig = make_subplots(