jkf
jkf

Reputation: 81

Seaborn ticklabels are being truncated

I'm using the Seaborn heatmap function with customized yticklabels. My labels are quite long, and they are being truncated even when I shrink the fontsize. Is there a way to allow longer visible tick labels?

ax = sns.heatmap(
        pcolor_data, 
        xticklabels=day_columns, 
        yticklabels=line_sales_by_day['product_name'][0:n_skus].values, 
        annot=True, 
        cbar=True, 
        annot_kws={'size':10}, 
        fmt='g', 
        cmap=cmap
        )

Upvotes: 8

Views: 9500

Answers (1)

tmdavison
tmdavison

Reputation: 69223

Have you tried the tight_layout option from matplotlib.pyplot?

ax = sns.heatmap(...)

ax.figure.tight_layout()

Alternatively, you can control the edges of your subplot area with subplots_adjust, a method of the plt.figure instance, which you can access with ax.figure.subplots_adjust():

ax = sns.heatmap(...)

ax.figure.subplots_adjust(left = 0.3) # change 0.3 to suit your needs.

Upvotes: 14

Related Questions