简体   繁体   English

如何使用 plotly 中的子图规格?

[英]How to use specs for subplots in plotly?

I want to create a 2x2 subplot with 3 plots.我想用 3 个图创建一个 2x2 子图。

The first plot in whole first row (1X2).整个第一行 (1X2) 中的第一个 plot。 Second and Third plot, below,第二和第三 plot,下,

My Code:我的代码:

fig = make_subplots(
    rows=2, cols=2,
    specs=[[{"colspan": 2}, None],
          [{}, {}]],
    subplot_titles=("Patents","Institutions", "Countries"))

I get the following error:我收到以下错误:

    ValueError: 
No subplot specified at grid position (1, 2)

But the plot in first row second column (1,2) is specified as None, or?但是第一行第二列 (1,2) 中的 plot 被指定为无,或者?

I also tried it with rowspan, but got the same error.我也用rowspan尝试过,但得到了同样的错误。

Stupid me, i forgot to specifie the position of each plot in the愚蠢的我,我忘了指定每个 plot

fig.add_trace(go.xx(), rows=i, cols=k)

ie IE

fig = make_subplots(
    rows=2, cols=2,
    specs=[[{"colspan": 2}, None],[{}, {}]],
    subplot_titles=("First Subplot","Second Subplot", "Third Subplot"))

fig.add_trace(go.Bar(x=years, y=freq),row=1,col=1)

fig.add_trace(go.Scatter(x=[1, 2], y=[1, 2]),
                 row=2, col=1)

fig.add_trace(go.Scatter(x=[1, 2], y=[1, 2]),
                 row=2, col=2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM