简体   繁体   English

使用Seaborn的数据可视化条形图

[英]Data Visualization Barplot using seaborn

I want to display a barplot using seaborn. 我想使用seaborn显示一个小样图。 The name, number of categories to display on the x-axis is large and they are getting jumbled together. X轴上显示的类别的名称和数量很大,并且它们混杂在一起。 What can I do to present the categories in a clean way? 我该怎么做才能干净地展示类别?

尝试使用seaborn ser,以更改字体的大小

sns.set(font_scale = 2)

I have understand your problem like this way, You want to display all category name of respective column on x-axis. 我已经这样理解您的问题,您想在x轴上显示相应列的所有类别名称。

So, for that follow bellow code snippet and put x = category column y = numeric data 因此,对于下面的代码段,将x =类别列y =数字数据

#import libraries
import seaborn as sns # for data visualization
import matplotlib.pyplot as plt # for data visualization

#load tips DataFrame
tips_df =  sns.load_dataset("tips")

plt.figure(figsize = (200, 9)) # barblot size in 200:9 ratio

# plot barplot in horizontal order
sns.barplot(x = tips_df.tip, y = tips_df.total_bill, orient = "h") 

click here to see result 点击这里查看结果

I suggest you draw seaborn barplot horizontal. 我建议您水平绘制seaborn barplot。 It will show proper way. 它将显示正确的方式。

plt.figure(figsize = (9, 200)) # barblot size in 9:200 ratio
# plot barplot in vertical order
sns.barplot(x = tips_df.total_bill, y = tips_df.tip, orient = "v") 

I hope you will satisfy with above solution. 希望您能满意以上解决方案。 I recommended you follow seaborn barplot tutorial for better understanding. 我建议您按照seaborn barplot教程进行操作,以更好地理解。 This is neat and clear to understand. 这很容易理解。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM