Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to rotate column labels #20

Open
komalsrathi opened this issue Nov 18, 2015 · 4 comments
Open

Unable to rotate column labels #20

komalsrathi opened this issue Nov 18, 2015 · 4 comments

Comments

@komalsrathi
Copy link

Hi,

Here is my code:

pheatmap(mat, display_numbers = T, scale = 'row',clustering_distance_rows = 'correlation', main = "Differentially Expressed Genes\n", cellwidth = 70 , cellheight = 10)

This is the result:
rplot02

But my column names are too long and I'd like to rotate them by say 45 degrees. Is that possible?

Thanks!

@Ihmor
Copy link

Ihmor commented Feb 23, 2016

I've got the same issue. It seems that pheatmap is the only plotting package that rotates the lables by 270° than by 90° ;)

If dublicated draw_colnames as draw_colnames_90 with my preferred values. But that's obviously an ugly hack. It would be great, if the rot value could be a separate parameter to call in pheatmap() itself. But I can't provide a comprehensive code proposition...

Here the hack:
change "elem = do.call(draw_colnames, pars)" to
"elem = do.call(draw_colnames_90, pars)" and add the following function:

draw_colnames_90 = function(coln, gaps, ...){
coord = find_coordinates(length(coln), gaps)
x = coord$coord - 0.5 * coord$size

res = textGrob(coln, x = x, y = unit(1, "npc") - unit(3, "bigpts"), vjust = 0.5, hjust = 1, rot = 90, gp = gpar(...))

return(res)

}

@jdreyf
Copy link

jdreyf commented Aug 3, 2018

It looks like pull #23 provided an implementation of this but the branch hasn't been merged. @raivokolde Are you thinking of incorporating these changes?

pheatmap is really nice, thanks.

@saeedfc
Copy link

saeedfc commented May 27, 2020

Hi,
Maybe try a work around by breaking the lines if that serves the purpose?

labels_col <- mgsub::mgsub(colnames(mat), pattern = c("Sample_", "MEP_"), replacement = c("Sample\n", "MEP\n"))

@meshik
Copy link

meshik commented Nov 15, 2021

Has an implementation been introduced to the package?
I would love to rotate my x labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants