在Matplotlib中使用三叶草符号绘制散点图
要在Matplotlib中使用三叶草符号绘制散点图,可以按照以下步骤进行-
- 设置图形大小并调整子图之间和周围的填充。
- 使用numpy创建 x, y和z数据点。
- 使用 scatter()方法 绘制 x,y和s。
- 设置X和Y轴标签。
- 在绘图的左上方放置一个图例。
- 要显示图形,请使用 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轴")
plt.ylabel("Y轴")
plt.legend(loc='upper left')
plt.show()