第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用自定義繪圖標(biāo)題時(shí),“plotly.subplots”中的注釋會(huì)中斷

使用自定義繪圖標(biāo)題時(shí),“plotly.subplots”中的注釋會(huì)中斷

慕哥9229398 2023-06-20 16:05:04
我有一個(gè)奇怪的問(wèn)題 - 不確定這是一個(gè)錯(cuò)誤還是我遺漏了什么。當(dāng)繪制子圖并Code 1為每個(gè)子圖分配自定義標(biāo)題時(shí) - 我稍后嘗試添加到底部圖的注釋沒(méi)有完全顯示,但只顯示最后兩個(gè) ( Output Plot 1)。代碼 1:import numpy as npfrom plotly.subplots import make_subplotsfrom math import expfig = make_subplots(2, 1, subplot_titles=['Activation', 'Prediction errors - Model, ALO and RND'])x = np.linspace(0, 10, 100)y = np.array(list(map(lambda x: 1 / (1 + exp(-0.1 * x + 5)), x)))fig.add_trace(    go.Scatter(        x=x,        y=y,        name=f'\N{Greek Small Letter Sigma}(x)',        showlegend=True    ),    row=1,    col=1)fig['layout']['xaxis'].update(title_text='x')for i in range(4):    x = np.where(np.random.randint(0, 2, 100)==1)[0]    fig.add_trace(        go.Scatter(            x=x,            y=np.zeros_like(x) + i,            name=f'Plot {i}',            mode='markers',             marker=dict(                    symbol='circle-open',                    color='green',                    size=5                ),            showlegend=True        ),        row=2,        col=1    )fig['layout']['xaxis2'].update(title_text='active users', range=[0, 10], autorange=True)fig['layout']['yaxis2'].update(title_text='active users', visible=False, autorange=True)fig['layout'].update(    annotations=[    dict(x=0, y=0.125, xref='x2', yref='y2', text='True activity', font=dict(size=10, color='green')),    dict(x=0, y=1.125, xref='x2', yref='y2', text='Model', font=dict(size=10, color='blue')),    dict(x=0, y=2.125, xref='x2', yref='y2', text='ALO', font=dict(size=10, color='red')),    dict(x=0, y=3.125, xref='x2', yref='y2', text='RND', font=dict(size=10, color='black')),    ])fig.show()輸出圖 1另一方面,如果我刪除自定義繪圖標(biāo)簽 - 一切都按預(yù)期工作,如Code 2和輸出所示Image 2。
查看完整描述

1 回答

?
蝴蝶不菲

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超4個(gè)贊

我不確定這是否是由于字幕設(shè)置引起的,但是add_annotation()是正確的,update(annotations=[]可能已被函數(shù)覆蓋以更新已設(shè)置的注釋。


import plotly.graph_objects as go

import numpy as np

from plotly.subplots import make_subplots

from math import exp


fig = make_subplots(2, 1, subplot_titles=('Activation', 'Prediction errors - Model, ALO and RND'))


x = np.linspace(0, 10, 100)

y = np.array(list(map(lambda x: 1 / (1 + exp(-0.1 * x + 5)), x)))

fig.add_trace(

    go.Scatter(

        x=x,

        y=y,

        name=f'\N{Greek Small Letter Sigma}(x)',

        showlegend=True

    ),

    row=1,

    col=1

)

fig['layout']['xaxis'].update(title_text='x')


for i in range(4):

    x = np.where(np.random.randint(0, 2, 100)==1)[0]

    fig.add_trace(

        go.Scatter(

            x=x,

            y=np.zeros_like(x) + i,

            name=f'Plot {i}',

            mode='markers', 

            marker=dict(

                    symbol='circle-open',

                    color='green',

                    size=5

                ),

            showlegend=True

        ),

        row=2,

        col=1

    )

fig['layout']['xaxis2'].update(title_text='active users', autorange=True)

fig['layout']['yaxis2'].update(title_text='active users', visible=True, range=[-1,4])


fig.add_annotation(

    dict(x=0, y=3.125, xref='x2', yref='y2', text='RND', showarrow=True, font=dict(size=10, color='black'))

)

fig.add_annotation(

    dict(x=0, y=2.125, xref='x2', yref='y2', text='ALO', showarrow=True, font=dict(size=10, color='red'))

)

fig.add_annotation(

    dict(x=0, y=1.125, xref='x2', yref='y2', text='Model', showarrow=True, font=dict(size=10, color='Blue'))

)

fig.add_annotation(

    dict(x=0, y=0.125, xref='x2', yref='y2', text='True activity', showarrow=True, font=dict(size=10, color='green'))

)


fig.show()

http://img1.sycdn.imooc.com//64915df80001610206270332.jpg

查看完整回答
反對(duì) 回復(fù) 2023-06-20
  • 1 回答
  • 0 關(guān)注
  • 124 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)