0

I've been attempting to create a line graph with subplots for each column of a dataframe in Pandas. My dataframe has variable names as the column names, datetime objects as the columns, and percentages (floats) as the values. I'm referencing Plotly: How to create subplots from each column in a pandas dataframe?, but when adapted for my scenario it results in a blank figure - no exceptions or anything, and it does print out an empty box whose size I can adjust, but nothing in it.

My code is

from plotly.subplots import make_subplots
import plotly.graph_objects as go
# get the number of columns
num_alerts = len(helpfulness_graph_data.columns)
# Get the alert names
alert_types = helpfulness_graph_data.columns.values.tolist()
# Create a subplot figure object with 1 column, num_rows rows, and titles for each alert
fig = make_subplots(
    rows=num_alerts, cols=1,
    subplot_titles=alert_types)

j = 1
for i in helpfulness_graph_data.columns:
    #print(helpfulness_graph_data[i].values)
    fig.append_trace(
        go.Scatter(
            {'x': helpfulness_graph_data.index, 
             'y': helpfulness_graph_data[i].values}), 
             row=j, col=1)
    j += 1

fig.update_layout(height=1200, width=600, title_text="Helpfulness Over Time")
fig.show()
dhsmith
  • 250
  • 1
  • 2
  • 11

1 Answers1

0

For anyone else who comes across this: This happens when running plotly in jupyterlab sometimes apparently - I found some additional questions with suggested solutions, but none of them worked for me; What did work however was running it in plain old Jupyter. That's what I'd recommend.

dhsmith
  • 250
  • 1
  • 2
  • 11