在使用 PyCharm 時如何獲取 pyplot 的互動式繪圖?


要在使用 PyCharm 時獲取 pyplot 的互動式繪圖,我們可以採取以下步驟 −

  • 設定圖形大小並調整子圖之間的以及周圍的填充。

  • 設定背景樣式。

  • 在座標軸上繪製資料。

  • 要顯示圖形,可使用 show() 方法。

示例

import matplotlib as mpl
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

mpl.use('Qt5Agg')

plt.plot(range(10))

plt.show()

輸出

更新時間: 2021 年 9 月 23 日

3K+ 瀏覽次數

開啟你的職業生涯

完成課程認證

立即開始
廣告
© . All rights reserved.