为此问题提供了解决方案。然而,对于更新版本的海运(0.11.2),它不工作,而是产生一个单一颜色的散点图。
以下是先前提出的解决方案:
import matplotlib.pyplot as plt
import seaborn as sns
df = sns.load_dataset("iris", cache=True)
g = sns.PairGrid(df)
g.map_upper(sns.scatterplot)
g.map_diag(sns.kdeplot)
# Now set parameters needed for `hue`
g.hue_vals
嗨,我在海上安排约会时间有困难。我试图用x作为数据类型datetime.time绘制一个分类数据,但我得到了以下错误:
float() argument must be a string or a number, not 'datetime.time'
这是我的df:
toronto_time description
0 00:00:50 STATS
1 00:01:55 STATS
2 00:02:18
事实证明,当尝试在pyplot和seaborn中绘制相同的合成生成的二维点的numpy数组(一个有12个数据点,另一个只有1个数据点)时,我必须更改单点数组的数组维数,以便程序不会产生错误:
points = np.array([[1,2],[5,6],[4,1],[3,8],[7,5],[1,5],[0,8],[4,3],[2,1],[1,7],[3,8],[2,5]])
p = np.array([2.5,2])
import matplotlib.pyplot as plt
plt.style.use("ggplot")
plt.plot(points[:,0], po
我正在传递一只熊猫的数据,要用pd.scatterplot绘制,并希望使用'bright'调色板。颜色将由整数级数中的值来决定,我作为hue传递给绘图函数。
问题是,只有当hue系列只有两个不同的值时,这才有效。当它只有一个矿石超过两个不同的值,绘图默认为米色到紫色调色板。
当使用sns.set_palette('bright')设置调色板时,一切都会如前所述。但是,当我在绘图函数调用中执行palette='bright'(和n_classes is != 2)时,会抛出一个显式值错误:
ValueError: Palette {} not un
如何只从的提取或从.predict返回
MRE
import pandas as pd
import numpy as np
from sklearn.datasets import load_iris
from sklearn.neighbors import KNeighborsClassifier
import seaborn as sns
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
# prepare data
iris = load_iris()
X = iris.data