How do I combine two plots into one figure using Plotly?

I have 2 csv files, my codes are as below.

df = pd.read_csv("test.csv",
             sep='t',skiprows=range(9),names=['A', 'B', 'C','D'])

df2 = pd.read_csv("LoadMatch_Limit.csv",skiprows=range(1),names=['X','Y'])

fig = px.line([df,df2], x=['A','X'] , y=['D','Y'])

I would like my line chart, x-axis to take from (columns ‘A’ and ‘X’) and my y-axis to take from (columns ‘D’ and ‘Y’). Is there anyway I can plot these 2 charts as one figure?

Answer

You could create the two plots and combine them with plotly graph objects

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

fig1 = px.line(df, x='A', y='D')
fig2 = px.line(df2, x='X', y='Y')

fig = go.Figure(data = fig1.data + fig2.data)
fig.show()