Heatmap generation

你。 提交于 2019-12-21 05:16:09

问题


I have an Excel file with two different columns. One column have values ranging from 2 to 15 and other column have values ranging from positive to negative numbers.

I want to produce a heatmap in such a way that for first column each value should have a different color. Second column should be in the form of a gradient.

I tried using excel conditional formatting to do this.

But I want to know is there any way to do it in R?


回答1:


The R command image() takes a matrix and makes a heat-map from it. see the help page: ?image. Also worth considering is the heatmap function, which is basically image() with some clustering applied. Below are two examples from these two plotting routines:

image(volcano,col = terrain.colors(30))
heatmap(volcano,col = terrain.colors(30))

Probably the easiest way to export your data from Excel to R is to save it as a .csv file (comma or tab-separated text file), and then import it using read.table()




回答2:


You can easily create an interactive heatmap in R using plotly:

library(plotly)
plot_ly(z = volcano, type = "heatmap")

More instructions here.



来源:https://stackoverflow.com/questions/6998259/heatmap-generation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!