How do I put the color scales on heatmap.2?
0
0
Entering edit mode
3.1 years ago

Hello. I'm making a heatmap of my data using heatmap.2, but once the plot is done there is no color scale. Shouldn't it be done automatically? What function should I use to put it in the plot?

Also, I'm getting the mesage "Error in plot.new() : figure margins too large". I used the function margins =c() to lower the margins so that the image isn't cut, but I still get the mesage. Do I need to change something or is there no problem even if I get that mesage?

Thanks in advance.

heatmap.2 colorscale margins • 2.2k views
ADD COMMENT
0
Entering edit mode

Hi,

I guess that the color scale is not appearing due to the error that you're getting "Error in plot.new() : figure margins too large", so its being cut. This is my guess since I just searched for that function and it seems that gives a color scale (see the link).

Which are the dimensions (rows x cols) of your matrix? (that you're providing to the function)

António

ADD REPLY
0
Entering edit mode

There are 4 columns and 50 rows.

ADD REPLY
0
Entering edit mode

I just tried on RStudio (v.2021.09.0 Build 351), with R version 4.1.2, gplots version 3.1.1, on Ubuntu 20.04.3 LTS, and it worked fine.

The dummy example that I used:

# Create fake matrix: 50 x 4
set.seed(1024)
m <- matrix(data = sample(100:1000, 200), ncol = 4)
row.names(m) <- paste0("row_", 1:nrow(m))
colnames(m) <- paste0("col_", 1:ncol(m))

# Import package 
library("gplots")

# Plotting heatmap
heatmap.2(m)

# Save heatmap
pdf("Desktop/heatmap.pdf", height=12) # you may adjust height
heatmap.2(m)
dev.off()

Perhaps try to avoid giving the margins option/function first to see if it works.

I guess that this also depends on how long are your label row names and col names.

I hope this helps,

António

ADD REPLY
0
Entering edit mode

Thank you very much.

ADD REPLY
0
Entering edit mode

are you using rstudio while plotting this?

ADD REPLY
0
Entering edit mode

Yes, I am.

ADD REPLY
0
Entering edit mode

One reason could be plot window (panel) is not big. Just drag the borders of plotting window to make it bigger.

ADD REPLY

Login before adding your answer.

Traffic: 1023 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6