Remove the axis.y.text


I wrote a script and I had as a result the plot (view image). Everything was good until removing the "y axis text". As you can see in the image, on y axis (left), there is a text.
I would like to remove text and ticks and I already used this function: theme(axis.text.y =element_blank(), axis.title.y.left = element_blank()), but it is not working.
Do you have any solution for this problem?
Could be the problem by defining x and y in function "aes(x,y)''?

species_melt$porosite <- factor(species_melt$Porosite, levels = c("0,2-3um", "3-90um"))
species_melt$site <- factor(species_melt$Site, levels = c("Laz", "QN", "MIS", "Suf"))
tax<-ggplot(species_melt, aes(site,value))+ theme(axis.text.y =element_blank(), axis.title.y.left = element_blank())
tax + geom_bar(stat="identity" , aes(fill = variable), position = position_stack(reverse = TRUE)) +
coord_flip() +
  theme_bw() +
  facet_grid(site~porosite, scales = "free_y") +

Thanks in advance

It looks like you're almost there (but for the libraries, which hopefully contain species) — could you please turn this into a self-contained reprex (short for reproducible example)? It will help us help you if we can be sure we're all working with/looking at the same stuff.


If you've never heard of a reprex before, you might want to start by reading the help page. The reprex dos and don'ts are also useful.

What to do if you run into clipboard problems

If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.

reprex::reprex(input = "fruits_stringdist.R", outfile = "")

For pointers specific to the community site, check out the reprex FAQ.

In your code theme_bw() comes after theme(axis.text.y =element_blank(), axis.title.y.left = element_blank()). theme_bw() (and other overall themes, such as theme_grey(), theme_classic(), etc.) overwrites all of the theme elements, wiping out the results of the previous theme() statement. To fix this, move the theme() statement so that it comes after theme_bw(). Also, to remove the tick marks, use axis.ticks.y=element_blank().


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.