Seaborn: Clustermap row ticklabels no longer automatically rotated correctly

Created on 23 Feb 2016  路  9Comments  路  Source: mwaskom/seaborn

Most helpful comment

It is easy to rotate the tick labels yourself:

g = sns.clustermap(...)
plt.setp(g.ax_heatmap.get_yticklabels(), rotation=0)

Not everything needs to be a function parameter.

All 9 comments

A general solution here would be to default to having the labels oriented perpendicular to the axis and only rotate them parallel if they will fit. The code will be a little messier, but it is a better default to be able to see the labels but possibly use space less efficiently than the reverse.

(Actually the only reason the rotation wouldn't work correctly is because we're catching and ignoring an error from some matplotlib backends when checking for overlap, but that is a different problem...)

Having the same problem. May I make a suggestion?
It's very sweat that seaborn be able to detect everything and make the right choice for everyone. But sometimes some people want something otherwise.
May be can do something like this?
heatmap( ..., ticklabelrotation='auto') so we can have like x90y180 in degrees or xvyh for x-vertical and y-horizontal, or may be 1, 2, 3, 4 for defferent preset styles. Probably need a short name for ticklabelrotation.

It is easy to rotate the tick labels yourself:

g = sns.clustermap(...)
plt.setp(g.ax_heatmap.get_yticklabels(), rotation=0)

Not everything needs to be a function parameter.

OK, got it. Thanks for replying.

the proposed solution here is not working for me?

g = sns.clustermap(df,cmap="Blues", metric="correlation", standard_scale=1), plt.setp(g.ax_heatmap.get_yticklabels(), rotation=0)

AttributeError: 'tuple' object has no attribute 'ax_heatmap'

@dieudonnen it looks like you have a comma left over at the end of your first line there, so g is then a tuple like (ClusterGrid,). Removing the comma should fix it.

thanks, it works!

this proposed solution works fine, and I've used it quite a bit, but it still would be nice to have this as a function parameter or to default to horizontal labeling...

1) it doesn't make sense to me, at least, to default to vertical alignment, as any column-name longer than a single character or two _will_ be overlapping.
2) the proposed workaround is verbose enough that it's cumbersome and every time I want to do it I need to come back to this page to copy that code-block

This is annoying enough that I'd consider forking my own version or writing some other workaround 鈥斅爄n my mind, one shouldn't _need_ to dive into matplotlib's API to manipulate seaborn plots for something as simple as this

@alex2awesome it sounds like maybe you're just not using the latest version?

v0.8.1 (September 2017)

...

  • Fixed a bug in clustermap() where row labels were not being properly rotated when they overlapped.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

JanHomann picture JanHomann  路  3Comments

Bercio picture Bercio  路  3Comments

bondarevts picture bondarevts  路  3Comments

alexpetralia picture alexpetralia  路  3Comments

chanshing picture chanshing  路  3Comments