在一张图中绘制两个数字 (Python)

Plotting two figures in one graph (Python)

我想在一张图中显示两个数字,使它们相互重叠...

这是我的代码:

ohlc_data = pd.DataFrame(mt.copy_rates_range('EURUSD',
                                        mt.TIMEFRAME_D1,
                                        datetime(2021, 1, 1), 
                                        datetime.now()))

ohlc_data2 = pd.DataFrame(mt.copy_rates_range('EURUSD',
                                        mt.TIMEFRAME_H4,
                                        datetime(2021, 1, 1), 
                                        datetime.now()))

fig = px.line(ohlc_data, x=ohlc_data['time'], y=ohlc_data['close'])
fig2 = px.line(ohlc_data2, x=ohlc_data2['time'], y=ohlc_data2['close'])

如何在一张图中绘制 fig 和 fig2 而不是单独绘制?

这里是导入:

import MetaTrader5 as mt
import pandas as pd
import plotly.express as px
from datetime import datetime

如果两个地块共享相同的地块,您可以重复使用此示例x-axis:

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

df = px.data.gapminder().query("country=='Canada'")
fig1 = px.line(df, x="year", y="lifeExp", title='Life expectancy in Canada')
fig1.update_traces(line_color='red')

df = px.data.gapminder().query("country=='Australia'")
fig2 = px.line(df, x="year", y="lifeExp", title='Life expectancy in Australia')
fig1.update_traces(line_color='black')

fig3 = go.Figure(data=fig1.data + fig2.data)
fig3.update_xaxes(title_text="Yea")
fig3.update_yaxes(title_text="Life Expenses")

fig3.show()