Black Lives Matter. Please consider donating to Black Girls Code today.

Graph not displayed in JupyterLab

Hi,

I have problems with JupyterLab and plotly. When I use the code below, the chart is not displayed (large white space below). I tried to follow these Troubleshooting instructions (https://plot.ly/python/troubleshooting/) and many other things but it still doesn’t work. The same when I try to save as svg - fig(“svg”), while orca is installed.

Thanks in advance for your help


import pandas as pd
import numpy as np
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import technical_analysis as tech

Import Data

df = pd.read_excel(‘C:/Users/Admin/Desktop/Python/TA.xlsx’, header=[4,5], index_col=0)

Define stock or index for technical analysis

stock = “S&P 500”

Calculate the technical indicators

rsi = tech.RSI(df[stock][“Close”])
stoch = tech.Stoch(df[stock][“High”],df[stock][“Low”],df[stock][“Close”])
tsi = tech.TSI(df[stock][“High”])
macd = tech.MACD(df[stock][“Close”])

Plot results

fig = make_subplots(rows=2, cols=1)

fig.add_trace(go.Scatter(
x=[rsi.index],
y=[rsi],
mode=‘lines’)
, row=1, col=1)

fig.add_trace(go.Scatter(
x=[tsi.index],
y=[tsi],
mode=‘lines’)
, row=2, col=1)

fig.show()

Hi,
I’m also experiencing a similar problem.
I’m learning to use plotly with jupyterlab

import plotly.graph_objects as go
from plotly.offline import plot
import plotly.io as pio

fig = go.Figure(data = go.Scatter(x = dates, y = cases))
fig.show()

And all I get is a big empty space where the graph should be between the two cells. When I use the ‘jupyterlab’ renderer there is simply nothing.
However when I use:

plot(fig)

I do get my chart in a different tab.
Last thing the graph is properly displayed when run the code in jupyter.

many thanks for any help