![](/img/trans.png)
[英]How to create a bar plot with shared x-axis using plotly.express with sub-titles on top?
[英]How to create a subplot with shared x-axis and range slider in Python Plotly
我正在嘗試用Python和Plotly創建一個特定的情節。 我想知道是否有可能創建一個帶有3個垂直排列的子圖( https://plot.ly/python/subplots/ )的圖,它有一個共享的x軸,以及一個控制x軸的范圍滑塊( https ://plot.ly/python/range-slider/ )?
截至2017年1月,你不能這樣做,請看這里: https : //github.com/plotly/plotly.js/issues/1250
今天,2017年1月24日,我設法創建了共享一個x軸的堆積圖,並結合了一個范圍滑塊。 但是,問題是y軸的范圍是自動設定的。 我無法控制它。 這對我來說是個問題。 我的代碼是:
trace_1 = go.Scatter(
x=time_station1,
y=turb_station1,
mode = 'lines+markers',
name = 'Turbidity',
connectgaps = False,
marker = dict(
size = 5,
color = 'rgb(64, 97, 139)',
line = dict(
width = 1,
color = 'rgb(64, 97, 139)'
)
)
)
trace_2 = go.Scatter(
x=time_station1,
y=battery_station1,
yaxis='y2',
mode = 'lines+markers',
name = 'Battery',
connectgaps = False,
marker = dict(
size = 5,
color = 'rgb(117, 15, 7)',
line = dict(
width = 1,
color = 'rgb(117, 15, 7)'
)
)
)
trace_3 = go.Scatter(
x=time_station1,
y=cond_station1,
yaxis='y3',
mode = 'lines+markers',
name = 'Conductivity',
connectgaps = False,
marker = dict(
size = 5,
color = 'rgb(130, 0, 132)',
line = dict(
width = 1,
color = 'rgb(130, 0, 132)'
)
)
)
trace_4 = go.Scatter(
x=time_station1,
y=depth_station1,
yaxis='y4',
mode = 'lines+markers',
name = 'Depth',
connectgaps = False,
marker = dict(
size = 5,
color = 'rgb(204, 100, 0)',
line = dict(
width = 1,
color = 'rgb(204, 100, 0)'
)
)
)
trace_5 = go.Scatter(
x=time_station1,
y=temp_station1,
yaxis='y5',
mode = 'lines+markers',
name = 'Temperature',
connectgaps = False,
marker = dict(
size = 5,
color = 'rgb(255, 255, 0)',
line = dict(
width = 1,
color = 'rgb(255, 255, 0)'
)
)
)
layout = go.Layout(
title='Station ABC',
xaxis = dict(
rangeselector=dict(
buttons = list([
dict(count=1,
label='1min',
step='minute',
stepmode='backward'),
dict(count=24,
label='24h',
step='hour',
stepmode='backward'),
])
),
rangeslider=dict(),
type='date',
title='Date and Time'
),
yaxis=dict(
domain=[0,0.15]),
yaxis2=dict(
domain=[0.2,0.35]),
yaxis3=dict(
domain=[0.4,0.55]),
yaxis4=dict(
domain=[0.4,0.75]),
yaxis5=dict(
domain=[0.8,1]),
)
data = [trace_1, trace_2, trace_3, trace_4, trace_5]
plot_url = py.plot(fig, filename='offline plot.html')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.