Hi All,
I am trying to make a stacked bar plot in ggplot2.
When I import the data to R, it adds an "X" letter in the values from the "X" axis. How can I fix it? Ideally, the x-axis should have only the values (3,40,153..). Here is the "head" from the table after I import it.
Cluster Presence X3 X40 X153.5 X187.5 X213.5 X233.9 X283.4 X382
1 Genome cluster 1 Genome with dsrB gene present 0 0 0 0 0 1 1 1
2 Genome cluster 2 Genome with dsrB gene present 0 0 0 0 0 0 0 1
Here is the code:
>ready_to_plot_supermatrix <- read.csv("/Users/paularod/Documents/clusters_mapping_lever_MAGs.csv", header=TRUE)
>plotDat <- reshape::melt(ready_to_plot_supermatrix)
>ggplot(plotDat, aes(variable, Cluster, fill = Presence, alpha = value)) + geom_tile(colour = "gray50") + scale_alpha_identity(guide = "none") + coord_equal(expand = 0) + theme_bw() + theme(panel.grid.major = element_blank(), axis.text.x = element_text(angle = 45, hjust = 1)) + labs(x = "Sediment depth (cm)", y = "Genomes clustered at 97% identity", fill = "dsrB gene presence" ) + scale_fill_manual(values = coloursb)
Thank you very much!
Paula.
What code did you use to generate the plot?
I've never experienced this with ggplot. Can you post the results when you
head
your dataframe going into ggplot? Can you also post your ggplot code so we can see your arguments ingeom_bar
?