How to prevent overlapping x-axis labels in sns.countplot

后端 未结 5 807
天涯浪人
天涯浪人 2020-12-04 12:15

For the plot

sns.countplot(x=\"HostRamSize\",data=df)

I got the following graph with x-axis label mixing together, how do I avoid this? Sho

5条回答
  •  Happy的楠姐
    2020-12-04 12:53

    You can rotate the x_labels and increase their font size using the xticks methods of pandas.pyplot.

    For Example:

    import matplotlib.pyplot as plt
    plt.figure(figsize=(10,5))
    chart = sns.countplot(x="HostRamSize",data=df)
    
    plt.xticks(
        rotation=45, 
        horizontalalignment='right',
        fontweight='light',
        fontsize='x-large'  
    )
    

    For more such modifications you can refer this link: Drawing from Data

提交回复
热议问题