-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotly_timeseries_twiny.py
More file actions
31 lines (25 loc) · 1.07 KB
/
Copy pathplotly_timeseries_twiny.py
File metadata and controls
31 lines (25 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pandas as pd
import plotly.graph_objects as go
import plotly.io as pio
from plotly.subplots import make_subplots
hob = pd.read_csv('H26_20190531.csv', skiprows=2, usecols=[1, 2, 3],
names=['time', 'T', 'RH'],
index_col='time', parse_dates=True)
hob = hob.resample('W').mean()
fig = make_subplots(specs=[[{"secondary_y": True}]])
#fig = go.Figure(go.Scatter(x=hob.index, y=hob['T']))
fig.add_trace(go.Scatter(
x=hob.index,
y=hob['T'],
name="Temperature"),secondary_y=False)
fig.add_trace(go.Scatter(
x=hob.index,
y=hob['RH'],
name="RH",
#line_color='deepskyblue',
opacity=0.8),secondary_y=True)
fig.update_xaxes(title_text="Datetime - UTC")
fig.update_yaxes(title_text="Temperature (°C)", secondary_y=False)
fig.update_yaxes(title_text="RH (%)", secondary_y=True)
fig.update_layout(title_text='H26')
pio.write_html(fig, file='H26_temp_rh.html', auto_open=True)