New 'labelalias' argument in plotly not working in streamlit

There is a new ‘labelalias’ argument in plotly 5.15.0

If I am using the script in the example but add it into streamlit:

import plotly.express as px
import pandas as pd
import streamlit as st

df = px.data.tips()
df = (
    df[df.day.isin(["Sat", "Sun"])]
    .groupby(by="day", as_index=False)
    .sum(numeric_only=True)
)

fig = px.bar(df, x="day", y="total_bill")
fig.update_xaxes(labelalias=dict(Sat="Saturday", Sun="Sunday"))


st.plotly_chart(fig)
fig.show()

st.plotly_chart(fig) shows it in streamlit, and the labelalias is not working
the fig.show() opens it in a new tab, where the labelalias is working

I dont know if this is the reason, but I have noticed that
the fig.show() uses plotly.js 2.24.1 to view the plot


while within streamlit, the st.plotly_chart(fig) uses plotly 2.18.1 to view the plot

how can I fix that?
can I control which plotly.js version is used to render the plots?

any suggestions?

bump

Another bump

Hi @alonsh ,

You cannot control the plotly.js version used by Streamlit, and this is probably why you cannot use the new plotly feature yet. Streamlit dependencies are updated every now and then, but my suggestion is that you open an enhancement request on GitHub. Share the link here so people know and add thumbs up to the request to express interest :slight_smile:

give thumbs up if this is also relevant for you :slight_smile:

2 Likes

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