Seaborn错误:找不到“高度”,它去哪了?

时间:2018-10-23 06:12:46

标签: python seaborn init

从海底和山脊线绘图开始。对于Python来说还是很新的东西,我正在Spyder 3中工作。我想首先使用下面显示的示例:

import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="white", rc={"axes.facecolor": (0, 0, 0, 0)})

# Create the data
rs = np.random.RandomState(1979)
x = rs.randn(500)
g = np.tile(list("ABCDEFGHIJ"), 50)
df = pd.DataFrame(dict(x=x, g=g))
m = df.g.map(ord)
df["x"] += m

# Initialize the FacetGrid object
pal = sns.cubehelix_palette(10, rot=-.25, light=.7)
g = sns.FacetGrid(df, row="g", hue="g", aspect=15, height=.5, palette=pal)

# Draw the densities in a few steps
g.map(sns.kdeplot, "x", clip_on=False, shade=True, alpha=1, lw=1.5, bw=.2)
g.map(sns.kdeplot, "x", clip_on=False, color="w", lw=2, bw=.2)
g.map(plt.axhline, y=0, lw=2, clip_on=False)

# Define and use a simple function to label the plot in axes coordinates
def label(x, color, label):
    ax = plt.gca()
    ax.text(0, .2, label, fontweight="bold", color=color,
            ha="left", va="center", transform=ax.transAxes)

g.map(label, "x")

# Set the subplots to overlap
g.fig.subplots_adjust(hspace=-.25)

# Remove axes details that don't play well with overlap
g.set_titles("")
g.set(yticks=[])
g.despine(bottom=True, left=True)

也可以在https://seaborn.pydata.org/examples/kde_ridgeplot.html

上找到

我主要想了解在使用该软件包之前所有功能如何首先运行,但是FacetGrid的'height'参数无法通过__ init __识别。该错误具体显示为:

“ __ init __()收到了意外的关键字参数'height'”

我尝试在Python 2.7和3.5中运行时都没有运气。如果以前已回答过此问题,请直接引导我到正确的页面,因为我无法通过自己的搜索找到答案。

0 个答案:

没有答案