การใช้สัญลักษณ์ Clover (♣) ใน Scatter Plot
ใช้ LaTeX marker r'$\clubsuit$' ใน scatter()
ขั้นตอนหลัก
- ตั้งค่าขนาดรูปและ padding
- สร้างข้อมูล x, y, z (z ใช้เป็น size)
- พล็อต scatter() พร้อม marker=r'$\clubsuit$'
- ตั้งค่า axis labels และ legend
- แสดงผลด้วย show()
ตัวอย่างโค้ด
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
x = np.arange(0.0, 50.0, 2.0)
y = x ** 1.3 + np.random.rand(*x.shape) * 30.0
s = np.random.rand(*x.shape) * 800 + 500
plt.scatter(x, y, s, c=x, alpha=0.5, marker=r'$\clubsuit$',
label="Legend", cmap="plasma")
plt.xlabel("X-Axis")
plt.ylabel("Y-Axis")
plt.legend(loc='upper left')
plt.show()
คำอธิบาย
marker=r'$\clubsuit$' ใช้ LaTeX math symbol สำหรับสัญลักษณ์ club (♣) ต้องการ usetex=False (ค่าเริ่มต้น)