我在文本文件(data.csv)中有(x,y)数据我想在R中制作热像图https://www.youtube.com/watch?v=cFGu3O30a3w enter image description here
答案 0 :(得分:2)
那样的东西?
library(tidyverse)
library(echarts4r)
df<-data.frame(x=sample(50,5000,replace = T),
y=sample(50,5000,replace = T))
df%>%
count(x,y)%>%
e_chart(x)%>%
e_heatmap(y,n) %>%
e_visual_map(n)%>%
e_title("Heatmap")
答案 1 :(得分:0)
您还可以创建2D直方图,如下所示:
library(gplots)
# number of bins in both dimensions
resolution <- 50
# toy data (sorry about copying from jyjek)
df <- data.frame(x=sample(resolution,5000,replace = T),
y=sample(resolution,5000,replace = T))
# the shown example has "jet" palette
jet.colors <-
c("#00007F", "blue", "#007FFF", "cyan", "#7FFF7F", "yellow", "#FF7F00", "red", "#7F0000")
# the example has no margins
par(mar=c(0,0,0,0))
# plot the histogram without axes
hist2d(df, nbins=resolution, xaxt="n", yaxt="n", col=jet.colors)