I have (x,y) data in a text file (data.csv) I would like to make into a heat map in R like this https://www.youtube.com/watch?v=cFGu3O30a3wenter image description here
            Asked
            
        
        
            Active
            
        
            Viewed 232 times
        
    0
            
            
        - 
                    3Hi! Welcome to SO. Please read - [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to make a great R reproducible example?](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Your question is too broad, make an attempt and let us know where you are stuck – Shique Jun 13 '18 at 10:12
2 Answers
2
            
            
        Something like that?
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")
 
    
    
        jyjek
        
- 2,627
- 11
- 23
0
            
            
        You can also create a 2D histogram, like that:
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)
 
    
    
        Surak of Vulcan
        
- 348
- 2
- 11
