我正在尝试用非常稀疏的数据创建countourplot,而不使用插值。我想创造这样的东西
换句话说,我想创建一个“scatterplot/countourplot hybrid”。在matplotlib中这可能吗?如果是,怎么办?我应该使用countourf()还是scatterplot()?或者完全是别的什么?你知道吗
我在下面创建了一个示例数据集。你知道吗
非常感谢!你知道吗
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
In [1]:
d = {'col1': [0, 0, 0, 0, 0], 'col2': [0, 0.1, 0, 0, 0], 'col3': [0, 0.9, 0, 0, 0],
'col4': [0, 0, 0, 0.3, 0], 'col5': [0, 0, 0, 0, 0]}
df = pd.DataFrame(data=d)
df = df.replace(0, np.nan)
Out [1]:
col1 col2 col3 col4 col5
0 NaN NaN NaN NaN NaN
1 NaN 0.1 0.9 NaN NaN
2 NaN NaN NaN NaN NaN
3 NaN NaN NaN 0.3 NaN
4 NaN NaN NaN NaN NaN
使用contourf()打印:
y = df.index.values
x = df.columns.values
z = df
fig1 = plt.contourf(x, y, z)
目前没有回答
相关问题 更多 >
编程相关推荐