Making UpSetR plot with title
2
5
Entering edit mode
7.0 years ago

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 • 8.0k views
ADD COMMENT
1
Entering edit mode

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)

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Related GitHub issue:

ADD REPLY
3
Entering edit mode
7.0 years ago

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.

ADD COMMENT
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
2
Entering edit mode
6.4 years ago
scott.lohr ▴ 20

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
)
ADD COMMENT

Login before adding your answer.

Traffic: 2079 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6