r - Custom colours with geom_tile -
if have data frame looks this:
name track position color 1 0 1 #009acd 2 b 1 15 #50568b 3 c 2 55 #8c7125 4 0 44 #009acd 5 b 3 98 #50568b 6 d 0 99 #77df98
what correct way use geom_tile each level of name column plotted track x-axis point, position y-axis point, , color actual color of tile?
it should this:
we need set col
, fill
argument color
variable, use scale_color_identity
, scale_fill_identity
:
library(ggplot2) df1 <- read.table(text = "name track position color 0 1 #009acd b 1 15 #50568b c 0 55 #8c7125 0 44 #009acd b -1 98 #50568b d 0 99 #77df98",header=true,comment.char = "") ggplot(df1, aes(track, position, col = color, fill = color)) + geom_tile() + scale_color_identity() + scale_fill_identity() + #prettify theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.ticks.y = element_blank(), axis.text.y = element_blank(), axis.title = element_blank())
Comments
Post a Comment