Plotly dendogram chart not showing right side

App is running locally:

I am currently trying to create a dendogram chart which looks like the below in streamlit

But looks like this in jupyter notebook

image

(this is of a different dataset but the idea is the whole chart appears)

The right side of the chart is not showing on streamlit but is doing so in jupyter notebook.

Is there a way to rectify this?

The data:

data = [
  {
    "index": "HP Regen",
    "Akai": 0.6666666666666666
  },
  {
    "index": "Physical Defense",
    "Akai": 0.4
  },
  {
    "index": "HP",
    "Akai": 0.8666666666666667
  },
  {
    "index": "Magic Defense",
    "Akai": 0.4
  }
]

import plotly.figure_factory as ff 
from scipy.cluster.hierarchy import dendrogram, linkage 

df_data = pd.DataFrame(data) 
df_data.index = df_data.iloc[:,0]
df_data = df_data.iloc[:,1:]
fig_hier = ff.create_dendrogram(df_data, linkagefun=lambda x: linkage(x, "ward"), orientation='bottom', labels=df_data.index.tolist())

st.plotly_chart(fig_hier, use_container_width=True)

You are creating the pandas dataframe and the plot using the variable data_ and not using the data that you provided. From the plot, they seem to be different objects.

Sorry, typo. Creating dataframe from data not data_

sorry, my bad. You see different plots because streamlit applies their own theme by default. To get the plotly defaults, pass the kwarg theme=None to st.plotly_chart:

Ahh, great that did it. Thanks!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.