我想创建两个图,每个图包含多个子图和共享的XAX,并将它们添加到一个图中。子图中的多个图建议使用 Jmeter 板,但我对该解决方案不满意,我不相信在这种情况下您可以共享XAX。
我希望创建具有子图的图形,例如以下示例:
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
# Sub figure 1
sub_fig1 = make_subplots(rows=2, cols=1, shared_xaxes=True, vertical_spacing=0.02)
candlestick1 = go.Candlestick(x=df['Date'],
open=df['AAPL.Open'],
high=df['AAPL.High'],
low=df['AAPL.Low'],
close=df['AAPL.Close'])
sub_fig1.add_trace(candlestick1, row=1, col=1)
sub_fig1.add_trace({'x': df['Date'], 'y': df['AAPL.Volume'], 'type': 'bar', 'name': 'Volume'}, row=2, col=1)
sub_fig1.update_layout(xaxis_rangeslider_visible=False)
# Sub figure 2
sub_fig2 = make_subplots(rows=2, cols=1, shared_xaxes=True, vertical_spacing=0.02)
candlestick2 = go.Candlestick(x=df['Date'],
open=df['AAPL.Open'],
high=df['AAPL.High'],
low=df['AAPL.Low'],
close=df['AAPL.Close'])
sub_fig2.add_trace(candlestick2, row=1, col=1)
sub_fig2.add_trace({'x': df['Date'], 'y': df['AAPL.Volume'], 'type': 'bar', 'name': 'Volume'}, row=2, col=1)
sub_fig2.update_layout(xaxis_rangeslider_visible=False)
sub_fig1.show()
sub_fig2.show()
# Add both sub figures to one subplot
# ???
理想情况下,我希望在同一行中相邻的列上添加这些子图。可能吗?
在运行上面的代码后,我得到了下面的图,但正如我所说的,我希望这些数字并排在同一行上。
暂无答案!
目前还没有任何答案,快来回答吧!