**1.0k**wrote:

Dear All,

I would like to plot a multiple bar plot as shown below against the same y axis. So, I can observe the trend across different samples.

```
a<-c(rep("C1",3),rep("C2",5),rep("C4",4))
des<-c("ab","cd","de","ab","cd","de","ef","fg","ab","bc","cd","de")
count<-c(23:34)
x<-data.frame(a,des,count)
ggplot(x,aes(x=des,y=count,fill=a))+geom_bar(position="fill")+coord_flip()
```

I get the following image with some warnings.

```
Mapping a variable to y and also using stat="bin".
With stat="bin", it will attempt to set the y value to the count of cases in each group.
This can result in unexpected behavior and will not be allowed in a future version of ggplot2.
If you want y to represent counts of cases, use stat="bin" and don't map a variable to y.
If you want y to represent values in the data, use stat="identity".
See ?geom_bar for examples. (Deprecated; last used in version 0.9.2)
```

What I would like is to have multiple plots from different dataframes like `x`

in above example and be able to plot them one next to each other such that the y axis is same... so comparison of such a trend across samples would be possible.

I am wondering,

- how to achieve the ordering in y axis and
- if a particular y axis element is not present in another dataframe, would it be possible to have a blank space in the corresponding bar space of the graph?

Any help will be very much appreciated. Thanks a lot in advance!

**20**• written 6.9 years ago by k.nirmalraman •

**1.0k**

For aligning your plots, you will need to look at the

`gridExtra`

package and you can use`+scale_x_discrete()`

to manually order your samples across the plots (what you are called the "y axis" is the x-axis because you used`coord_flip()`

in your call to ggplot). I didn't test anything, but that should be a start. As far as the warnings, did you try`+geom_bar(stat="identity")`

? The warnings give clear advice on what to do and where to get more information.8.3k