如何讓 Matplotlib.pyplot 停止強制改變我的標記樣式?


為了讓 matplotlib.pyplot 停止強制更改標記樣式,我們可以採取以下步驟 -

  • 設定圖形大小並調整子圖之間的以及周圍的填充。
  • 使用 numpy 建立隨機的 xy 資料點。
  • 使用 plot() 方法,用 "r*" 標記(大小為 markersize=10)繪製 xy 資料點。
  • 要顯示圖形,請使用 show() 方法。

示例

from matplotlib import pyplot as plt
import numpy as np

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

x = np.random.rand(20)
y = np.random.rand(20)

plt.plot(x, y, 'r*', markersize=10)

plt.show()

輸出

更新於: 09-06-2021

109 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

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