0

With Python and Plotly I need to create one plot with 2 lines (for a and for a):

import plotly.express as px

a = [1, 2, 3, 4, 5]
b = [5, 4, 3, 2, 1]
fig = px.line([a, b])
fig.show()

However I am getting the following:

Plot

How to solve this?

1 Answer 1

1

The data need a title or label. My example uses a pandas dataframe:

import plotly.express as px
import pandas as pd

a = [1, 2, 3, 4, 5]
b = [5, 4, 3, 2, 1]

fig = px.line(pd.DataFrame({'line1':a, 'line2':b}))
# just dictionary will also work
# fig = px.line({'line1':a, 'line2':b})

fig.show()
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.