我希望在R中创建类似于以下类型的不连续热图的东西:
I wish to create something similar to the following types of discontinuous heat map in R:
我的数据安排如下:
k_e percent time .. .. .. .. .. ..我希望k_e是x轴,percent在y轴上,并且time表示颜色.
I wish k_e to be x-axis, percent on y-axis and time to denote the color.
我可以找到的所有链接都绘制了一个连续矩阵 http ://www.r-bloggers/ggheat-a-ggplot2-style-heatmap-function/或插值.但我不希望上述任何一种情况,我想绘制不连续的热图,如上图所示.
All links I could find plotted a continuous matrix www.r-bloggers/ggheat-a-ggplot2-style-heatmap-function/ or interpolated. But I wish neither of the aforementioned, I want to plot discontinuous heatmap as in the images above.
推荐答案第二个是十六进制图 如果您的(x,y)对是唯一的,则可以执行x y绘图,如果这是您想要的,则可以尝试使用基数R绘图函数:
The second one is a hexbin plot If your (x,y) pairs are unique, you can do an x y plot, if that's what you want, you can try using base R plot functions:
x <- runif(100) y<-runif(100) time<-runif(100) pal <- colorRampPalette(c('white','black')) #cut creates 10 breaks and classify all the values in the time vector in #one of the breaks, each of these values is then indexed by a color in the #pal colorRampPalette. cols <- pal(10)[as.numeric(cut(time,breaks = 10))] #plot(x,y) creates the plot, pch sets the symbol to use and col the color of the points plot(x,y,pch=19,col = cols)使用ggplot,您还可以尝试:
With ggplot, you can also try:
library(ggplot2) qplot(x,y,color=time)更多推荐
R中的选择热图
发布评论