python - 如何在 Python Pandas 中增加 countplot 的字体大小?
问题描述
我有以下代码创建的计数图:
plt.figure(figsize = (20,5))
ax=sns.countplot(x = "CompanyName", data = data)
ax.set_title("Number of passengers based on gender", fontsize = 20)
plt.xlabel("CompanyName",fontsize=17)
plt.ylabel("count", fontsize=17)
for p in ax.patches:
ax.annotate(f'\n{p.get_height()}', (p.get_x()+0.2, p.get_height()), color='black', size=15, ha="center")
我的问题是:如何增加对 y 轴值的描述。我想要例如“Alfa-romeo”、“Audi”、“Bmw”等等,用更大的字体书写。您可以更改我上面的代码以实现它吗?
解决方案
你可以试试这个:
#to increase y ticks size
plt.yticks(size=50)
#to increase x ticks
plt.xticks(size=50)
推荐阅读
- android - 如何将图像放在另一个图像之上?
- r - R:使用 ggplot2 刻面地图
- ruby-on-rails - Ruby on Rails - 阿拉伯文本有时会被编码,而其他文本则不会 - 为什么以及如何修复?
- python - 芹菜ignore_result无法正常工作
- javascript - 数据表,更新页脚信息 totalSize 值而不重绘表
- dynamics-crm - Dynamics 365 CE 统一接口 - 部分中的 2 列布局仅显示一列
- prometheus - Azure Monitor Containers 和 prometheus 集成
- java - 没有 Java SE DK,JAR 将无法运行
- r - 如果条件不成立,则生成具有缺失值的变量
- javascript - 使用 ramda 过滤嵌套对象数组中的值