Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีหยุดไม่ให้ Matplotlib.pyplot บังคับสไตล์ Markers เอง


เพื่อไม่ให้ matplotlib.pyplot บังคับสไตล์ markers เอง

  • ตั้งค่าขนาดรูปและ padding ระหว่าง subplots
  • สร้างข้อมูล x, y แบบสุ่มด้วย numpy
  • พลอต x, y ด้วย plot() ระบุ marker "r*" และ markersize=10
  • แสดงรูปด้วย 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()

ผลลัพธ์

วิธีหยุดไม่ให้ Matplotlib.pyplot บังคับสไตล์ Markers เอง