This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Making UpSetR plot with title

I'm using UpSetR to create UpSet diagrams like this, but I can't find a way to add a main title to the plot. Does anyone know if this functionality is possible in the UpSetR package at the moment?

plot r upsetr

Have you tried adding the usual R-option for a title in plot functions? --> main="acb"

Unfortunately that doesn't work. UpSetR has options for main.bar.color, mainbar.y.label, and mainbar.y.max, so calling main results in Error in upset(...) argument 7 matches multiple formal arguments

From their reference manual here, it seems there is no argument to add a title to the plot. (you can check one more time just in case if I missed it)

It looks like you're right, I'll have to add the title after with some other method

2 answers

Half-baked solution is to add the title to the image itself using the convert tool part of the ImageMagick suite. At least you can do it programmatically. For example:

convert -gravity North -annotate +0+0 'My Title' -pointsize 20 input.png output.png

This will add the text "My Title" on the upper side of the image (-gravity North) right in the middle. It can handle several image formats in input and output. ImageMagick is useful suite to have anyway...

EDIT

To choose a font just add the option -font, for example -font TimesNewRoman. To see available fonts you can use convert -list type.

I ended up going with a half-baked solution, although I used GIMP so I could match the font in the UpSetR plot to the title.

Hi- Glad you found a solution, but see my edit to set font.

+1. I use convert mostly to conver PDF to HQ PNG format. This is completely new to me. Thanks.

Yes... ImageMagick is quite a universe in itself, I just know the bare surface of it!

using this idea as a starting point: https://github.com/hms-dbmi/UpSetR/issues/63#issuecomment-306610220

you could try the following:

library(UpSetR)

movies <- read.csv(
  system.file("extdata", "movies.csv", package = "UpSetR"), 
  header = T, sep = ";"
)

upset(
  movies, nsets = 6, number.angles = 30, point.size = 3.5, line.size = 2, 
  mainbar.y.label = "Genre Intersections", sets.x.label = "Movies Per Genre", 
  text.scale = c(1.3, 1.3, 1, 1, 2, 0.75)
)

grid.edit('arrange', name="movies")
vp <- grid.grab()

grid.arrange(
  grobs = list(
    vp
  ),
  top="Choosing the Top Largest Sets and Plot Formatting",
  cols=1
)

Log in to answer this question.