const-ae / ggsignif

Easily add significance brackets to your ggplots
https://const-ae.github.io/ggsignif/
GNU General Public License v3.0
593 stars 43 forks source link

Is it possible to put the annotations in bold? #54

Closed natsrm closed 4 years ago

natsrm commented 5 years ago

Hi there!

Thanks a lot for a great (and sanity saving!) package! This is something small but I was wondering if it's possible to make the annotations of geom_signif in bold? I already saw it's possible to change the size (with textsize) and even the font (with family), but maybe I'm missing how to put it in bold?

Thanks in advance!

const-ae commented 5 years ago

Hi natsrm, I am happy to hear that you like the package. Unfortunately it is currently not possible to make the text bold. If you absolute need that, I guess the easiest way to achieve it would be to manually recreate the annotation using annotate(geom="text", ...) + geom_segment(...).

On the other hand the "correct" approach would be to extend ggsignif to support custom theme elements. Unfortunately I currently don't have the bandwith to implement this myself, so if you or anyone else ist interested, I would be happy to give pointers where to start and then merge a PR.

natsrm commented 5 years ago

Thank you Constantin :) Yes I was previously using the annotate, but I have many plots and having to write everything by hand was a little annoying, which is why I appreciate the ggsignif package so much!

I would help on the enhancement if I could but I'm not really a pro at coding ahaha so thank you anyways! And I hope someone tries to implement it :)

Best, Nats

davidmasp commented 4 years ago

I am not sure I understand the issue. Annotation should be the text or pvalue on top of the segment right?

I think you can simply use fontface then. It’s already mapped.

see here.

library(magrittr)
library(ggplot2)

iris %>% ggplot(aes(x = Species,y = Sepal.Length)) + 
  geom_boxplot() +
  ggsignif::geom_signif(comparisons = list(c("virginica","versicolor")),
                        fontface = "bold")


iris %>% ggplot(aes(x = Species,y = Sepal.Length)) + 
  geom_boxplot() +
  ggsignif::geom_signif(comparisons = list(c("virginica","versicolor")),
                        annotation = "test",
                        fontface = "bold.italic")

Created on 2020-01-09 by the reprex package (v0.3.0)

natsrm commented 4 years ago

Hey @davidmasp ,

You are right! I don't remember if I had tried to use fontface before, but I do feel quite dumb now ahaha. Thanks for the assist!

@const-ae given this, I guess the issue should be closed? Your call :)

const-ae commented 4 years ago

@davidmasp, thanks for your input, that is a great solution. I didn't realize myself this was possible :D