如何在 Matplotlib 中使用不斷增大的標記來繪製散點圖?


要使用增加的標記大小繪製散點圖,我們可以採取以下步驟:

步驟

  • 建立 x 和 y 資料點
  • 為獲取增加的標記大小,製作一個數字列表。
  • 使用**scatter**方法繪製散點圖。
  • 使用 show() 方法顯示圖片。

示例

from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = [0, 2, 4, 6, 8, 10]
y = [0] * len(x)
s = [10 * 4 ** n for n in range(len(x))]
plt.scatter(x, y, s=s, c='red')
plt.show()

輸出

更新於: 06-May-2021

698 瀏覽

開始您的 職業生涯

透過完成課程獲得認證

開始
廣告
© . All rights reserved.