設定 Matplotlib 中的可變點大小


要在 matplotlib 中設定可變點大小,我們可以執行以下步驟−

  • 初始化點的座標。
  • 建立一個用於儲存點大小的變數。
  • 使用 scatter 方法繪製點,marker=o、color=red、s=point_size。要顯示圖形,請使用 show() 方法。

示例

from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
xy = (3, 4)
point_size = 100
plt.scatter(x=xy[0], y=xy[1], marker='o', c='red', s=point_size)
plt.show()

輸出

更新於: 2021-05-06

360 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始學習
廣告
© . All rights reserved.