1

As the title says I need to remove the label related to the facet.by from the title of each subplot in a violin box plot, using ggplot2.

Read the data and create the plot

 plotIt <- read.table("tryit.csv", sep="\t", header=T)

 p <- ggviolin(data, x = "label", y = "aMeasure",  fill="label", palette=rainbowcols, + facet.by="timepoint", add.params = list(fill = "white"), short.panel.labs = FALSE, main=paste("measuring", tolower(reg), sep=" "), ylab="a measure", xlab="", ylim=c(0,8)) + theme(plot.title = element_text(hjust = 0.5), axis.text.x=element_blank())

 advanced <- p + stat_compare_means(comparisons = list(c("tone", "ttwo")), method = "t.test", paired=F, label.y=7.5) + geom_boxplot(width=0.05)

The question is: how to remove the "timepoint" label from the title of each subplot?

EDIT:

these are the packages I'm using for plotting are ggplot and ggpubr

the plot

gabt
  • 668
  • 1
  • 6
  • 20
  • 1
    Possibly `theme(strip.background = element_blank(), strip.text = element_blank() )` – Matt Aug 01 '19 at 14:20
  • would you like to just remove `timepoint: `? – dbo Aug 01 '19 at 14:44
  • @matt: that removes everything, not only `timepoint:` – gabt Aug 01 '19 at 14:46
  • @dbo, yes: that is exactly what I need. I must keep the day* but no `timepoint` – gabt Aug 01 '19 at 14:47
  • @tom, that doesn't do the trick but I'll look into the link you provided – gabt Aug 01 '19 at 15:06
  • With `library(tidyverse)` for `mutate()` I'd try something along the lines of `plotIt %>% mutate(timepoint = gsub("timepoint: ", "", timepoint)` – dbo Aug 01 '19 at 15:21
  • [See here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on making an R question that folks can help with. That includes a sample of data, and what packages you're using (`ggpubr`?) – camille Aug 01 '19 at 15:42
  • @camille, you're right. I was going to upload a sample file. Also I edited the question with the packages I'm importing – gabt Aug 02 '19 at 08:06
  • @dbo, what do you mean with "along the lines". I mean...your suggestion is supposed to substitute `timepoint: ` with nothing but when I plot, I need to specify which column of the dataset will be considered. Am I wrong? – gabt Aug 02 '19 at 08:11

1 Answers1

0

You should get the desired result by using:

short.panel.labs = TRUE

This is also the default behaviour of facet, so you can completely remove short.panel.labs. And it doesn't matter whether you use TRUE/FALSE or T/F, but if I remember correctly, the full notation is recommended for clarity.

Arienrhod
  • 2,451
  • 1
  • 11
  • 19
  • that is perfect! I totally missed this part in the help. Now that you mentioned it I found it. Many thanks! – gabt Aug 02 '19 at 08:32