The error message indicates that the 'col_span' argument is not recognized by the 'add_trace()' method.

This is because 'col_span' is not a valid argument for 'add_trace()'. Instead, you can achieve the desired effect by specifying the 'secondary_y' parameter for the trace that you want to span multiple columns.

Here's an updated code snippet that should work:

import plotly.graph_objects as go
from plotly.subplots import make_subplots 

fig = make_subplots(rows=1, cols=3, column_widths=[0.5, 0.25, 0.25])

# Adding first trace that spans two columns
fig.add_trace(
    go.Scatter(x=[1, 2, 3], y=[4, 5, 6]),
    row=1, col=1,
    secondary_y=True # Span two columns
)

# Adding second and third traces
fig.add_trace(
    go.Bar(x=[1, 2, 3], y=[2, 3, 4]),
    row=1, col=2
)

fig.add_trace(
    go.Pie(values=[1, 2, 3]),
    row=1, col=3
)

fig.show()

In this updated code, the secondary_y=True parameter is used to specify that the first trace should span two columns. This allows the second and third traces to be added to the second and third columns, respectively.

import plotlygraph_objects as go from plotlysubplots import make_subplots fig = make_subplotsrows=1 cols=3 column_widths=05 025 025 # 添加第一个图 figadd_trace goScatterx=1 2 3 y=4 5 6 row=1 col=1

原文地址: https://www.cveoy.top/t/topic/bkGW 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录