[英]Data Visualization Barplot using seaborn
我想使用seaborn显示一个小样图。 X轴上显示的类别的名称和数量很大,并且它们混杂在一起。 我该怎么做才能干净地展示类别?
尝试使用seaborn ser,以更改字体的大小
sns.set(font_scale = 2)
我已经这样理解您的问题,您想在x轴上显示相应列的所有类别名称。
因此,对于下面的代码段,将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")
我建议您水平绘制seaborn barplot。 它将显示正确的方式。
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")
希望您能满意以上解决方案。 我建议您按照seaborn barplot教程进行操作,以更好地理解。 这很容易理解。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.