Màu mặc định của scatter là màu xanh '#1f77b4' (tab:blue). Có thể annotate để so sánh.
- Tạo figure, axes.
- ax.scatter(-1, 1) → màu mặc định.
- ax.annotate("default color", xy=(-0.9, 1)).
- ax.scatter(1, 1, c='#1f77b4') → dùng mã hex.
- ax.annotate("using hex", xy=(1.1, 1)).
- Đặt xlim, ylim, show().
Ví dụ
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
fig, ax = plt.subplots()
ax.scatter(-1, 1)
ax.annotate("default color", xy=(-0.9, 1))
ax.scatter(1, 1, c='#1f77b4')
ax.annotate("using hex", xy=(1.1, 1))
ax.set_xlim(-2, 3)
ax.set_ylim(-1, 2)
plt.show()
Kết quả
Hai điểm scatter cùng màu xanh, một dùng mặc định, một dùng mã hex #1f77b4.