Để vẽ điểm scatter với ký hiệu clover (câyクラブ) trong Matplotlib:
- Thiết lập kích thước hình và điều chỉnh khoảng đệm subplot.
- Tạo x, y, z dữ liệu bằng numpy.
- Vẽ x, y, s bằng scatter().
- Đặt nhãn trục X, Y.
- Đặt legend ở góc trên trái.
- Hiển thị hình bằng show().
Ví dụ
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()
Kết quả
