Removing Legends from the Library's Built-in Chart Function

Therefore, I use a library in R called DVHmetrics . The idea is that you can take some data from a specific file exported by another program, and pretty much read it and manage the data inside. It also means that this is not the raw data that I work with here.

This library has a function called showDVH that takes some data from the file you are reading and scoop it up. Looking at the code behind the library, this graph runs through ggplot. However, when using the function that makes this construction, there is no way to show / not show legends. And I really need to remove the legends.

So, is there a way, when possible, if it is not directly implemented in the function itself?

+4
source share
1 answer

The package function returns a list of ggplot objects, so we need to say โ€œwithout legendโ€ for each ggplot object in the list separately, see the example below:

library(DVHmetrics)
library(ggplot2)

# for one patient
x <- showDVH(dataMZ, patID = "P123", show = FALSE)
x <- x$P123 + theme(legend.position = "none")
# plot
x

# for all patients
x <- showDVH(dataMZ, show = FALSE)
x <- lapply(x, function(i) i + theme(legend.position = "none"))
# plot
x
+3
source

Source: https://habr.com/ru/post/1688808/


All Articles