【发布时间】:2022-01-11 11:33:41
【问题描述】:
我有一个这样的数据框:
| x | y | height |
|---|---|---|
| 1 | 1 | NaN |
| 2 | 5 | 20 |
| 3 | 10 | 100 |
| 4 | 7 | NaN |
| 5 | 6 | NaN |
| 6 | 12 | 500 |
我需要为 x-y 创建一个气泡图,其中“高度”作为点大小的变量(当它是 NaN 时使用其他标记)。
我正在尝试以这种方式调节高度变量,但没有成功。
fig = plt.figure()
ax = fig.add_subplot()
ax.scatter(x, y, marker='o', c='k', s=height)
ax.scatter(x[height==np.nan], y[height==np.nan], marker='^', c='r')
【问题讨论】:
-
请提供足够的代码,以便其他人更好地理解或重现问题。
标签: python matplotlib nan colormap bubble-chart