I was using the function below to create a heatmap from a matrix of 48 columns X 32 rows:
heatmap.2(all.data,Rowv = FALSE, Colv = FALSE, trace="none",main="All data",col=colorRampPalette(c("green","yellow","red")))
It was giving me some warnings because of the removal of the dendograms, but still it gave me the heatmap I wanted plus the color key, something happend and now when I try to run the same it gives me the plot without the color key and an error:
Error in plot.new() : figure margins too large
In addition: Warning messages:
1: In heatmap.2(all.data, Rowv = FALSE, Colv = FALSE, trace = "none", :
Discrepancy: Rowv is FALSE, while dendrogram is `both'. Omitting row dendogram.
2: In heatmap.2(all.data, Rowv = FALSE, Colv = FALSE, trace = "none", :
Discrepancy: Colv is FALSE, while dendrogram is `none'. Omitting column dendogram.
if I change the margins to 1 for all sides:
par(mar=c(1,1,1,1))
heatmap.2(all.data,Rowv = FALSE, Colv = FALSE, trace="none",main="All data",col=colorRampPalette(c("green","yellow","red")))
and try again it doesn't make the heatmap and gives me this error:
Error in .External.graphics(C_layout, num.rows, num.cols, mat, as.integer(num.figures), :
invalid graphics state
In addition: Warning messages:
1: In heatmap.2(all.data, Rowv = FALSE, Colv = FALSE, trace = "none", :
Discrepancy: Rowv is FALSE, while dendrogram is `both'. Omitting row dendogram.
2: In heatmap.2(all.data, Rowv = FALSE, Colv = FALSE, trace = "none", :
Discrepancy: Colv is FALSE, while dendrogram is `none'. Omitting column dendogram.
I also tried adding to the function key=T, but the color key is still not appearing in the Heatmap, any help will be very much appreciated!!!
If your plot has been working in the past and is now throwing the invalid graphics state
error, try resetting the graphics device by calling dev.off()
. This was suggested by RStudio's help site.
Figured it out, it was just a mistake with the display, if I automatically save the plot instead of asking RStudio to show it to me is, the graph is ok
I also found this problem in RStudio. It can be solved by increasing vertical size of plot window in RStudio (otherwise part of plot doesn't fit to the window and error occured).
I did that by maximizing the window, before it was stacked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With