This is a test version of Biostars. For the public version, visit https://www.biostars.org.
plotting stacked bar plot with different number and kinds of variables

Hi,

I am trying to create a stacked bar plot using the data below. I want to show A, C and D on the x axis. "A" has four variables (GCU,GCC,GCA,GCG) and I want to show these variables as a stacked bar with their percentages (as shown in the last column). I tried to use ggplot but could not make it. Any help will be appreciated.

enter image description here

stackedbarplot ggplot

Please do not paste screenshots of plain text content, it is counterproductive. You can copy paste the content directly here (using the code formatting option shown below), or use a GitHub Gist if the content volume exceeds allowed length here.

code_formatting

Thanks for the information. I did not know this option.
I am going to use it for my new posts.

1 answer

It shouldnt be too difficult using ggplot2, but try the R package ggpubr for something more user friendly.

ggbarplot(data = mat , x = "code", y = "percent", fill = "codon" ) 

Log in to answer this question.