python - Python数据标签问题
问题描述
我想创建一个多个子图,我需要在散点旁边绘制一个带有学生姓名的散点图。但不知何故,我明白了。我不知道我应该做什么改变。请检查我的输出和代码。
#creating the subplots
fig, axes = plt.subplots(1, 4, figsize=(12,3))
df = pd.DataFrame(data, columns =['Averagemarks', 'Name'])
x = df["Name"]
y = df["Averagemarks"]
rslt_df = df.loc[(df['Averagemarks'] > 0) & (df['Averagemarks'] <= 60), 'Name']
rslt_df1 = df.loc[(df['Averagemarks'] > 61) & (df['Averagemarks'] <= 70), 'Name']
rslt_df2 = df.loc[(df['Averagemarks'] > 71) & (df['Averagemarks'] <= 80), 'Name']
rslt_df3 = df.loc[(df['Averagemarks'] > 81) & (df['Averagemarks'] <= 100), 'Name']
#Subplot D
ax1 = plt.subplot(2, 2, 1, frameon=True)
plt.title("Student's in the range 'D'")
subplt = sns.scatterplot(rslt_df, y, color = 'red')
plt.yticks(np.arange(0, 61, 5))
plt.xticks(rotation = 90, size = 8)
subplt.s[enter image description here][1]et_facecolor('#E5E7E9')
'''for p in zip(subplt.get_xticks(), x): subplt.text(p[0], p 1 +8.5, p 1 , color='k',fontsize = 13)'''
for i,j in enumerate(rslt_df.astype(str)):
subplt.text(i+0.1,i,j,fontsize = 6,color="b")
plt.show()
解决方案
推荐阅读
- python - 如何知道python多处理中的进程何时结束
- json - 仅当 JSON 属性存在时才排除它 - Powershell
- excel - Conditional Formatting, best way to highlight this?
- c++ - BOOST::HANA get all member names and iterate
- c - What's goes wrong with this code? What is runtime error?
- typescript - Typescript - 使用泛型和参数值来设置类型
- c# - 这个多线程应用程序出现在 Windows 任务管理器中的什么位置?
- excel - 在 excel 中使用嵌套的 IF 函数:有没有办法检查下一行是否有相同的 IF 函数?
- node.js - 如何解决“MODULE_NOT_FOUND”错误?
- asp.net-mvc - 如何通过 Microsoft Dynamics 的组织服务获取不同语言的 OptionSet 值和 Formatted 值?