Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
        )
like image 261
jkf Avatar asked Nov 11 '15 21:11

jkf


1 Answers

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.
like image 89
tmdavison Avatar answered Sep 22 '22 19:09

tmdavison