Search code examples
rggplot2statisticsannotationsbar-chart

geom_signif() overlaps asterisks/stars when manually plotting on a cluster bar graph?


I created a dataframe that contains my asterisks and details to show statistics on the graph:

#this is index_df dataframe
xmin xmax y   sym
0.8  1.2  4.5 *
0.8  1.8  5.5 ****
1.2  2.2  6.5 *
1.8  2.2  4.5 *

And i apply it the the bargraph (i.e. plot) by geom_signif()

plot<- plot+geom_signif(
      data = index_df,
      aes(xmin=index_df$xmin_index,
          xmax=index_df$xmax_index,
          annotations=index_df$sym,
          y_position=index_df$y),
      textsize=6,size=0.7,vjust=0.5,manual=TRUE,inherit.aes = FALSE)}
  

The output is the following: enter image description here

As you can see, geom_signif() has overlapped * when there should be three separate *.

I have tried hjust, but it didn't work


Solution

  • I've fixed it by using geom_bracket() from the ggpubr library instead.

    plot<- plot+geom_bracket(
          aes(xmin=index_df$xmin_index,
              xmax=index_df$xmax_index,
              label=index_df$sym,
              y.position=index_df$y),
          data=index_df,inherit.aes = FALSE)}