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

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

安裝ggp??lot后matplotlib出現(xiàn)問題

安裝ggp??lot后matplotlib出現(xiàn)問題

慕尼黑8549860 2021-06-08 16:41:44
昨天,我將 ggplot 安裝到了我的 anaconda 環(huán)境中。當(dāng)我嘗試使用在安裝 ggplot 之前工作的 matplotlib 圖時(shí),出現(xiàn)以下錯(cuò)誤。我也收到來自其他內(nèi)聯(lián) jupyter 實(shí)驗(yàn)室代碼的錯(cuò)誤。任何幫助將不勝感激。我是可視化數(shù)據(jù)的新手。如果我應(yīng)該使用另一個(gè)繪圖模塊,請(qǐng)告訴我。plt.rcParams['figure.dpi'] = 200plt.rcParams.update({'font.size': 5})fig, ax1 = plt.subplots()ax1.set_xlabel('Time')ax1.set_ylabel('price', color='k')ax1.plot(df['price'], color='#0072b5', label = 'price')ax1.tick_params(axis='y', labelcolor='k')#ax1.tick_params(axis='x',  labelrotation = 90) ax2 = ax1.twinx()  # instantiate a second axes that shares the same x-axis#color = 'tab:cyan'ax2.set_ylabel('gen', color='k')  # we already handled the x-label with ax1ax2.plot(df['gen'], color='#e2e3e2', label = 'gen')ax2.tick_params(axis='y', labelcolor='k')#ax1.legend(loc=2)#ax2.legend(loc=1)fig.legend(loc=1, bbox_to_anchor=(1,1), bbox_transform=ax1.transAxes, prop={'size':5})fig.tight_layout()  # otherwise the right y-label is slightly clippedfig.suptitle('%s, %s %s' % (df, month_graph, year_graph) , fontsize=8)fig.subplots_adjust(top=0.90)plt.savefig("%s.png" % ('genPrice'))plt.show()---------------------------------------------------------------------------TypeError                                 Traceback (most recent call last)<ipython-input-14-032d973b53a3> in <module>()     19 #ax1.legend(loc=2)     20 #ax2.legend(loc=1)---> 21 fig.legend(loc=1, bbox_to_anchor=(1,1), bbox_transform=ax1.transAxes, prop={'size':5})     22      23 TypeError: legend() missing 2 required positional arguments: 'handles' and 'labels'
查看完整描述

2 回答

?
阿波羅的戰(zhàn)車

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

回溯指出缺少兩個(gè)“必需”參數(shù),盡管根據(jù)文檔,它們實(shí)際上是可選的。如果您在安裝新模塊后遇到此問題,那么您可能已將 matplotlib 降級(jí)到必須使用兩個(gè)參數(shù)的先前版本。如果是這種情況,您可能需要pip install matplotlib --upgrade從控制臺(tái)。


查看完整回答
反對(duì) 回復(fù) 2021-06-16
?
白豬掌柜的

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

對(duì)于簽名matplotlib.figure.Figure.legend是在2.0.2版本matplotlib的


legend(handles, labels, *args, **kwargs)

而在 2.1.2或更高版本中它是


legend(*args, **kwargs)

這意味著您在安裝 ggplot 期間降級(jí)了 matplotlib。如果您想繼續(xù)使用這個(gè)較舊的 matplotlib 版本,您需要自己提供句柄和標(biāo)簽。這可能看起來像


h1, l1 = ax1.get_legend_handles_labels()

h2, l2 = ax2.get_legend_handles_labels()


fig.legend(h1+h2, l1+l2, loc=1, bbox_to_anchor=(1,1), 

           bbox_transform=ax1.transAxes, prop={'size':5})


查看完整回答
反對(duì) 回復(fù) 2021-06-16
  • 2 回答
  • 0 關(guān)注
  • 225 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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