I am currently struggeling with the use of ggplot. I have the following data:
num <- c(5,5,5,5,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8)
name <- c('4;1','4;1','4;1','4;1','4;2','4;2','4;2','3;3','4;2','3;3','4;2','3;3','4;2','4;3','3;4','4;3','3;4','4;3','3;4','4;3','3;4','4;3','3;4','4;3','3;4','4;3','4;4','4;4','4;4','4;4','4;4','4;4','4;4','4;4')
x <- c(1.7,1.8,1.9,2.0,1.5,1.6,1.7,1.8,1.8,1.9,1.9,2.0,2.0,1.4,1.5,1.5,1.6,1.6,1.7,1.7,1.8,1.8,1.9,1.9,2.0,2.0,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0)
min <- c(1.0,0.5,0.3,1.4,1.2,0.8,0.5,1.3,0.3,1.0,0.3,1.4,1.4,1.1,1.4,0.8,1.2,0.5,1.0,0.4,0.8,0.3,0.7,0.3,1.0,0.6,1.1,0.9,0.7,0.5,0.3,0.3,0.3,0.4)
max <- c(1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,0.6)
df <- data.frame(num,name,x,min,max)
As one can see, the data describes ranges of configurations.
What I want to do is something like that:
I tried the geom_bar option, but without success at all. Does anyone has an idea, how I can use ggplot for this data and that type of plot?
P.S. The x-axis should be df$x
, y-axis should be range(df$min, df$max)
. The color should depend on df$name
.
df$num
is just to group the data. Sometimes there is only one df$name
for one df$num
, sometimes there are two df$name
for one df$num
.