Alex T
Alex T

Reputation: 3764

Spacing between bars or labels

so I'm trying to set the spacing between x labels or somehow make spaces between every bar in every subplot in the chart so that they wouln't overlap eachother even a little bit. I've tried rotating but some of the x labels are still overlapping and it doesn't look right. How can I make it more visually appealing?

g=sns.factorplot(x='type1', col='type2',col_wrap=3, data=dframe, kind='count', sharex=False, sharey=False, palette=pokemon_color_palette)

for ax in g.axes.flat:
    for label in ax.get_xticklabels():
        label.set_rotation(60)


for ax in g.axes.flat:
    ax.set_xlabel('type1', color='indianred')

plt.tight_layout()

example charts

Upvotes: 3

Views: 6816

Answers (2)

Lucas
Lucas

Reputation: 7341

Why do not you turn the labels 90°? That way they will never overlap.

    label.set_rotation(60)

Result:

enter image description here

Also you could not show the xlabel when there is no pokemon with those types.

Upvotes: 1

Ted Petrou
Ted Petrou

Reputation: 62037

Why don't you shrink the size of the tick labels.

ax.tick_params(axis='x', labelsize=10)

Upvotes: 2

Related Questions