1

I have the following dataset:

db1.1 <- data.frame(Status1.1 = rep(c("Completed", "Ongoing"), each=9),code1.1= rep(c(1:9), times=2), nProj1.1 = c(-24,-2,-17,-59,-1,-12,-6,0,0,0,2,3,5,0,2,0,1,1)) 

With this dataset, I build a graphic very similar to this one (code1.1 is the x axis, nProj1.1 is the y axis, and Status1.1 gives the two different grey tones):

enter image description here

I used this code to build the graphic:

ggplot(db1.1, aes(x=code1.1, y=nProj1.1, fill=Status1.1)) + geom_bar(stat="identity", position="identity")+coord_flip()+geom_hline(yintercept = 0, size=1)

However, I want to add a new variable/overlap a graphic, to obtain the following result:

enter image description here

Basically, it is the same as the one above but with values over the grey bars, with the dashed lines.

I have a new dataset that should correspond to the bars with dashed lines, with the same variables:

db1.2 <- data.frame(Status1.2 = rep(c("Completed", "Ongoing"), each=9),code1.2= rep(c(1:9), times=2), nProj1.2 = c(0,0,-14,-43,-1,-10,-5,0,0,0,2,3,5,0,1,0,0,1)) # manter assim, que já atribui a classe a cada variavel; ex.: factor, num, int, etc

I tried following this question: R-stacked-grouped barplot with different fill in R , but I didn't manage yet to make it work. I can also group both datasets and create a new binary variable, but I am not sure if that would help.

Does anyone know how can I make this kind of graph?

mto23
  • 303
  • 1
  • 5
  • 15
  • Maybe this can help ? https://stackoverflow.com/a/57393584/10580543 – tom Sep 18 '19 at 08:46
  • @tom I didn't manage to get it right yet... The problem with that one if that only provides the "box", and I would like to have some pattern/texture – mto23 Sep 20 '19 at 09:54

0 Answers0