亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

matplotlib:更改活動軸

matplotlib:更改活動軸

鳳凰求蠱 2021-07-01 15:12:40
我有多個對象可以可視化不同的事物。它們都被傳遞到單個 Figure 實例的引用并創建自己的軸對象(同時只有一個處于活動狀態)演示代碼是:import numpy as npimport matplotlib.pyplot as plt# the visualization objects are jupyter widgets in production code%matplotlib widgetplt.ioff()def update_fig(f):    f.canvas.draw()    f.canvas.flush_events()f = plt.figure()# first visualizer is created and plots into the figureax1 = f.add_subplot(1,1,1, label="visualizer_1")img1 = np.random.randint(0, 256, (20, 20, 3))vis1 = ax1.imshow(img1)update_fig(f)# second visualizer is created and plots into the figureax2 = f.add_subplot(1,1,1, label="visualizer_2")vis2 = ax2.plot(np.linspace(0, 5), 2 * np.linspace(0, 5))update_fig(f)然后如何切換要在圖中顯示的軸?已經嘗試plt.sca(ax1)返回到第一個可視化,但沒有奏效。當然,我可以為每個可視化對象使用不同的圖形,但由于我有很多,我寧愿避免這種情況。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 92 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號