R中的选择热图

编程入门 行业动态 更新时间:2024-10-09 23:16:47
本文介绍了R中的选择热图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我希望在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中的选择热图

本文发布于:2023-07-18 14:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1145651.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:热图

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!