有人可以告诉我这里出了什么问题吗
\n#stemming all the words to their root word\nstemmer = SnowballStemmer(language='english')\nstem=[]\nfor word in lines:\n stem.append(stemmer.stem(word))\nstem[:20]\n#removes stopwords (very common words in a sentence)\nstem2 = []\nfor word in stem:\n if word not in nlp.Defaults.stop_words:\n stem2.append(word)\n#creates a new dataframe for the stem and shows the count of the most used words\ndf = pd.DataFrame(stem2)\ndf=df[0].value_counts()\ndf #shows the new dataframe\nRun Code Online (Sandbox Code Playgroud)\n我不知道这里出了什么问题,当我运行这些代码时遇到的错误 \xe2\xac\x87\xe2\xac\x87\xe2\xac\x87
\n#plots the top 20 used words\ndf = df[:20]\nplt.figure(figsize=(10,5))\nsns.barplot(df.values, df.index, alpha=0.8)\nplt.title('Top Words Overall')\nplt.xlabel('Count of words', fontsize=12)\nplt.ylabel('Word from Tweet', fontsize=12)\nplt.show()\nRun Code Online (Sandbox Code Playgroud)\n然后得到这些错误
\n …每个官方的seaborn演示/示例都以sns.load_dataset().我想知道在哪里可以获得这些seaborn数据集,以便我可以按照这些示例进行操作?
我试图使用"在哪里找到官方的seaborn数据集"等短语找到它们,但没有得到点击.
更新:
那么,我该如何使用它们呢?我正在关注http://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.boxplot.html,这是我得到的唯一一件事,即我没有获得任何图表.
我的seaborn和pandas都工作得很好.它们来自我的Anaconda安装,并且都是最新版本.我正在使用的matplotlib版本也适用于seaborn.
@gabra,我在问问题之前从互联网上找到了那些csv文件,因为我认为它们只是csv文件,不能直接使用sns.load_dataset(xxx),对吧?
我在Seaborn热图中存储标签时遇到问题.我拥有的标签很长.当我plt.show()用来显示我的情节时,我可以通过调整画布大小来查看完整标签.但是,当我保存到文件时,只存储标签的一小部分.我在Seaborn中使用了以下代码0.7.1:
ax = sns.heatmap(some_matrix)
ax.set_yticklabels(labels=some_labels,rotation=0)
fig = ax.get_figure()
fig.savefig("my_file.png",dpi=600)
Run Code Online (Sandbox Code Playgroud)
任何线索我如何增加画布的大小,以便完整的标签存储在我的.png文件中?减小字体大小可能不是一个好的解决方案,因为Y轴上有很多标签,导致标签变得不可读.
我想从 x 和 y 创建一个散点图,具有以下特征:
关于如何将这 3 个要求中的 2 个结合起来,我找到了很多答案。但是,我还没有看到它们全部联合实施,无论是在 seaborn 还是在 matplotlib 上。
我有4个点,想用它绘制矩形
a=[0,0]
b=[0,5]
c=[7,0]
d=[7,5]
Run Code Online (Sandbox Code Playgroud)
有没有办法使用matplotlib或seaborn绘制矩形?
seaborn ×5
python ×4
matplotlib ×3
bar-chart ×1
dataset ×1
plot ×1
python-3.x ×1
scatter-plot ×1