3
How do I remove the other tags generated by the function geom_errorbar()
?
I only need the marking that is circled in the image.
Database
dataset = structure(list(structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "BLOCO X", class = "factor"),
c(0L, 6L, 11L, 20L, 32L, 35L, 38L, 42L, 84L, 89L, 106L, 112L,
118L, 122L, 124L, 126L, 129L, 133L, 155L, 161L), c(6L, 11L,
20L, 32L, 35L, 38L, 42L, 84L, 89L, 106L, 112L, 118L, 122L,
124L, 126L, 129L, 133L, 155L, 161L, 203L), structure(c(1L,
2L, 3L, 2L, 3L, 2L, 3L, 2L, 3L, 4L, 3L, 2L, 3L, 4L, 3L, 2L,
3L, 2L, 3L, 4L), .Label = c("COR 1", "COR 2", "COR 3", "COR 4"
), class = "factor"), c(26265L, 215L, 0L, 215L, 0L, 215L,
0L, 215L, 0L, 4737279L, 0L, 215L, 0L, 4737279L, 0L, 215L,
0L, 215L, 0L, 4737279L), c(153L, 215L, 0L, 215L, 0L, 215L,
0L, 215L, 0L, 255L, 0L, 215L, 0L, 255L, 0L, 215L, 0L, 215L,
0L, 255L), c(102L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 72L, 0L,
0L, 0L, 72L, 0L, 0L, 0L, 0L, 0L, 72L), c(0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 72L, 0L, 0L, 0L, 72L, 0L, 0L, 0L, 0L,
0L, 72L), c(0L, 0L, 0L, 0L, 0L, 0L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 50L, 50L, 50L, 50L, 50L, 50L), c(20L, 20L,
20L, 20L, 20L, 20L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L,
100L, 100L, 100L, 100L, 100L, 100L), c("#996600", "#D70000",
"#000000", "#D70000", "#000000", "#D70000", "#000000", "#D70000",
"#000000", "#FF4848", "#000000", "#D70000", "#000000", "#FF4848",
"#000000", "#D70000", "#000000", "#D70000", "#000000", "#FF4848"
), c("#996600", "#D70000", "#000000", "#D70000", "#000000",
"#D70000", "#000000", "#D70000", "#000000", "#FF4848", "#000000",
"#D70000", "#000000", "#FF4848", "#000000", "#D70000", "#000000",
"#D70000", "#000000", "#FF4848")), .Names = c("ID", "GEOLFROM",
"GEOLTO", "LIT_01", "BACKCOLOR", "R", "G", "B", "ymin", "ymax",
NA, "HEX_COLOR"), row.names = c(NA, -20L), class = "data.frame")
Graph
library("ggplot2")
fun <- function(ref, cor){
cor <- as.character(cor)
x <- unique(ref)
i <- match(x, ref)
setNames(cor[i], ref[i])
}
dataset$LIT_01 = factor(as.character(dataset$LIT_01))
dataset$HEX_COLOR = rgb(dataset$R, dataset$G, dataset$B, maxColorValue = 255)
color_ref = with(dataset, fun(LIT_01, HEX_COLOR))
p = ggplot(dataset, aes(ID, (GEOLTO + GEOLFROM)/2, fill=LIT_01)) +
geom_tile(aes(height = (GEOLTO - GEOLFROM), width = 0.2), colour="black", size=0.1) +
geom_errorbar(aes(ymin = ymin , ymax = ymax), width = 0.3, position = position_dodge(1.1)) +
theme_classic() +
labs(x = "ID", y = "METERS") +
labs(fill = "LITHO") +
scale_fill_manual (values = color_ref, breaks = unique(dataset$LIT_01)) +
scale_y_reverse()
p