I have attempted adapting from some other solutions for slightly different situations. I am not being able to sort this out.
I would like to build a mirrored barplot comparing chemicals with controls, but with results grouped by chemical concentrations, and (if possible) both positive axes.
I provide data below, and an example of I would like it to generally look like.
volatiles<-c("hexenal3", "trans2hexenal", "trans2hexenol", "ethyl2hexanol", "phenethylalcohol", "methylsalicylate", "geraniol", "eugenol")
require(reshape2)
dat<-list(
conc1=data.frame("volatile"=volatiles, "focal"=c(26,27,28,28,31,31,30,28), "control"=c(24,31,30,29,24,23,21,25)),
conc2=data.frame("volatile"=volatiles, "focal"=c(29,18,34,17,30,32,35,27), "control"=c(21,42,20,40,25,16,17,29)),
conc3=data.frame("volatile"=volatiles, "focal"=c(33, 5,38, 7,37,35,40,26), "control"=c(18,51,14, 50,15,12,13,31))
)
long.dat<-melt(dat)
Attempting the following isn't working. Perhaps I should input a different data structure?
ggplot(long.dat, aes(x=L1, group=volatile, y=value, fill=variable)) +
geom_bar(stat="identity", position= "identity")
I would like it to look similar to this, but with the bars grouped in the triads of different concentrations (and, if possible, with all positive values).

Try this:
I suspect that the order on the left axis (originally
x, but flipped to the left withcoord_flip) will be relevant to you. If the current isn't what you need and usinginteraction(L1, volatile)instead does not give you the correct order, then you will need to combine them intelligently beforeggplot(..), convert to afactor, and control thelevels=so that they are in the order (and string-formatting) you need.Most other aspects can be controlled via
+ theme(...), such aslegend.position="top". I don't know what the asterisks in your demo image might be, but they can likely be added withgeom_point(making sure to negate those that should be on the left).For instance, if you have a
$starvariable that indicates there should be a star on each particular row,then you can add it with a single
geom_pointcall (and adding the legend move):