Seaborn Swarmplot 永远 运行 并且不会在 Jupyter Notebook 中打印绘图
Seaborn Swarmplot is running forever and not printing plot in Jupyter Notebook
Pandas 数据框有 "user_fair , user_good, rating" 这 3 列。
我正在使用 sns.swarmplot
绘制 "user_fair vs rating" 和 "user_good vs rating"。
"user_fair vs rating" 工作正常,但是当尝试绘制 "user_good vs rating" 代码时,代码将永远运行并且不会打印任何图。我正在使用 Python3
和 Jupyter Notebook
.
这是我使用的代码:
fig, ax = plt.subplots(figsize=(15, 15))
ax = sns.swarmplot(y="user_good", x="rating", data=data)
ax.set_xlabel("Rating",size = 20,alpha=0.8)
ax.set_ylabel("Goodness of User who got Rated",size = 20,alpha=0.8)
ax.set_title("Distributin of Rating and How are Goodness Score of ratee",size=20)
所以问题不在于您的代码,而在于群图的创建方式。 Swarmplots 创建点并确保 "points are adjusted (only along the categorical axis) so that they don’t overlap"。当您有大量数据并且有很多点重叠时,它会遇到困难,并且大多数 rating/user_good 值重叠。
我强烈推荐使用小提琴图。它会为您提供与您尝试通过群图识别相同的信息,并且工作速度会快得多。
fig, ax = plt.subplots(figsize=(15, 15))
ax = sns.violinplot(x="rating", y="user_good", data=df, cut = 0)
ax.set_xlabel("Rating",size = 20,alpha=0.8)
ax.set_ylabel("Goodness of User who got Rated",size = 20,alpha=0.8)
ax.set_title("Distributin of Rating and How are Goodness Score of ratee",size=20)
大部分时间尝试小提琴图,但当数据有更多异常值时,您也可以使用散点图。
fig, ax = plt.subplots(figsize=(15, 15))
ax = sns.scatterplot(y="user_good", x="rating", data=data)
ax.set_xlabel("Rating",size = 20,alpha=0.8)
ax.set_ylabel("Goodness of User who got Rated",size = 20,alpha=0.8)
ax.set_title("Distributin of Rating and How are Goodness Score of ratee",size=20)
Pandas 数据框有 "user_fair , user_good, rating" 这 3 列。
我正在使用 sns.swarmplot
绘制 "user_fair vs rating" 和 "user_good vs rating"。
"user_fair vs rating" 工作正常,但是当尝试绘制 "user_good vs rating" 代码时,代码将永远运行并且不会打印任何图。我正在使用 Python3
和 Jupyter Notebook
.
这是我使用的代码:
fig, ax = plt.subplots(figsize=(15, 15))
ax = sns.swarmplot(y="user_good", x="rating", data=data)
ax.set_xlabel("Rating",size = 20,alpha=0.8)
ax.set_ylabel("Goodness of User who got Rated",size = 20,alpha=0.8)
ax.set_title("Distributin of Rating and How are Goodness Score of ratee",size=20)
所以问题不在于您的代码,而在于群图的创建方式。 Swarmplots 创建点并确保 "points are adjusted (only along the categorical axis) so that they don’t overlap"。当您有大量数据并且有很多点重叠时,它会遇到困难,并且大多数 rating/user_good 值重叠。
我强烈推荐使用小提琴图。它会为您提供与您尝试通过群图识别相同的信息,并且工作速度会快得多。
fig, ax = plt.subplots(figsize=(15, 15))
ax = sns.violinplot(x="rating", y="user_good", data=df, cut = 0)
ax.set_xlabel("Rating",size = 20,alpha=0.8)
ax.set_ylabel("Goodness of User who got Rated",size = 20,alpha=0.8)
ax.set_title("Distributin of Rating and How are Goodness Score of ratee",size=20)
大部分时间尝试小提琴图,但当数据有更多异常值时,您也可以使用散点图。
fig, ax = plt.subplots(figsize=(15, 15))
ax = sns.scatterplot(y="user_good", x="rating", data=data)
ax.set_xlabel("Rating",size = 20,alpha=0.8)
ax.set_ylabel("Goodness of User who got Rated",size = 20,alpha=0.8)
ax.set_title("Distributin of Rating and How are Goodness Score of ratee",size=20)