One-column Heatmap

Hey guys,

I am qiute new in the world of R, so i would like to ask, if it's possible to create a diagramm that looks like a heatmap for only one column. So now I have two varables, the depth and the chemical value and my target is to color the depths according to their chemical values, nearly like in this photo.

Thanks for your ideas,

have you been working with ggplot2 before? If so, then you can use the geom_tile to create something like the graphic you posted.

Here an example:

# create a tibble with one column for depth and one for the value
depth<-seq(from=0, to=5,by=0.5)

# plot the heatmap 
 # add label inside the tiles:   
 #  flip y axis:
  scale_y_reverse(breaks = depth)+
 # remove x axis lable 
  theme( axis.text.x=element_blank())

From a data frame like this:

  depth value
   <dbl> <int>
 1   0       2
 2   0.5    16
 3   1      12
 4   1.5     7
 5   2      14
 6   2.5    19
 7   3      13
 8   3.5    15
 9   4       8
10   4.5    18
11   5       4

You will get this graphic:

1 Like

ggplot2 is new for me, but i just tried it and it works great. Thanks you very much for your help, kind regards, cacadu

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.