'Plotly python rows
I have code that looks like this. It works well, but I want to modify the size of columns:
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import pandas as pd
df=pd.read_csv('nasdaq.csv')
fig = make_subplots(rows=2, cols=1)
fig.append_trace(
go.Candlestick(
x=df.index,
open=df['Open'],
high=df['High'],
low=df['Low'],
close=df['Close'],
), row=1, col=1
)
fig.append_trace(
go.Scatter(
x=df.index,
y=df['S_slowK'],
line=dict(color='#ff9900', width=2),
name='Slow K',
), row=2, col=1
)
fig.append_trace(
go.Scatter(
x=df.index,
y=df['RSI'],
line=dict(color='blue', width=2),
name='RSI',
), row=2, col=1
)
fig.append_trace(
go.Scatter(
x=df.index,
y=df['S_FastD'],
line=dict(color='#000000', width=2),
name='Fast D'
), row=2, col=1
)
fig.update_yaxes(range=[-10, 110], row=2, col=1)
fig.add_hline(y=0, col=1, row=2, line_color="#666", line_width=2)
fig.add_hline(y=100, col=1, row=2, line_color="#666", line_width=2)
fig.add_hline(y=50, col=1, row=2, line_color="red", line_width=2)
fig.add_hline(y=20, col=1, row=2, line_color='#336699', line_width=2, line_dash='dash')
fig.add_hline(y=80, col=1, row=2, line_color='#336699', line_width=2, line_dash='dash')
fig.update_layout(xaxis_rangeslider_visible=False)
fig.update_layout(
width=1800,
height=800,
title_text= "nasdaq",
yaxis_tickformat='M')
fig.show()
However, he chart window and the indicators window have the same size. How can I make the chart bigger than indicators?
Solution 1:[1]
I have found the solution. Just add more arguments to the make subplots function like this:
fig = make_subplots(rows=2, cols=1,horizontal_spacing=0,row_heights=[15,2],vertical_spacing=0.01)
You can see row heights must be a list containing two numbers.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jeremy Caney |