1

With this script , it is open 2 dashboards and so 2 graphs How i can modify it to see all on the same graph ? dataframe:



    df = pd.DataFrame( df_abs.to_numpy()[:, 1:].T).reset_index().melt(id_vars="index")
    fig = px.line(df, x="index", y="value", color="variable")
    fig.show()

script dot plotly:

df_abs = pd.DataFrame(df_abs.loc[outlier].iloc[1:]).reset_index().melt(id_vars="index")
fig = px.line(df_abs, x="index", y="value", color="variable")
fig.show()

df = pd.DataFrame( df_abs.to_numpy()[:, 1:].T).reset_index().melt(id_vars="index")
fig = px.line(df, x="index", y="value", color="variable")
fig.show()

4

1 Answer 1

5

You need to use plotly.graph_objects instead of plotly.express.

plotly.express is great for quick plots but it is somewhat limited compared to plotly.graph_objects.

Here is a dummy example using 2 dataframes to make it similar to your case.

import plotly.graph_objects as go
import plotly.express as px

df1 = px.data.gapminder().query("country in ['Canada']")
df2 = px.data.gapminder().query("country in ['Italy']")

fig = go.Figure()
fig.add_trace(go.Scatter(x=df1["lifeExp"], y=df1["gdpPercap"], mode='lines', name='Canada'))
fig.add_trace(go.Scatter(x=df2["lifeExp"], y=df2["gdpPercap"], mode='lines', name='Italy'))
fig.show()

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.