gaospecial / ggVennDiagram

A 'ggplot2' implement of Venn Diagram.
https://gaospecial.github.io/ggVennDiagram/
GNU General Public License v3.0
277 stars 37 forks source link

Add custom themes to ggVennDiagram when force_upset = TRUE #68

Open sgarciah12 opened 5 months ago

sgarciah12 commented 5 months ago

Dear @gaospecial,

First, thanks for developing this amazing tool! ggVennDiagram has helped me make lots of figures until now.

I just found a little issue: ggVennDiagram accepts full customization using the ggplot2 grammar but when I try with force_upset = T, then it no longer works.

For example:

X = list(A = c(1,2,3,4), B = c(2,3,4,5), C = c(3,4,5,6))
ggVennDiagram(X) + theme(panel.background = element_rect(fill = "red"))

Which returns the following graph with the background in red: image

But, while I can do the same in ggVennDiagram with force_upset = T:

X = list(A = c(1,2,3,4), B = c(2,3,4,5), C = c(3,4,5,6))
ggVennDiagram(X, force_upset = T)

Which returns: image

If I now try to change the graph background (or any other theme property using the ggplot2 sintax) it returns:

ggVennDiagram(X, force_upset = T) + theme(panel.background = element_rect(fill = "red"))

NULL

Would it be possible to fix that so that customization of upset plots is easier following ggplot2's grammar? Thank you very much!

gaospecial commented 5 months ago

I am sorry, the upset plot is a complex graph type which can not be plot by ggplot2 directly. So it is not a ggplot class object, therefore, no longer modification can be made with theme() and other ggplot2 functions. If you want to customize the upset plot, please export the graph as a pptx or pdf file.

For example, you may export this graph to Powerpoint format.

# need export package
library(export)
ggVenndiagram()
export::graph2ppt(file = "venn.pptx")

and then edit the background by hand.

sgarciah12 commented 5 months ago

Dear @gaospecial ,

Thanks for your quick answer. I understand now, I did not know that it was not a ggplot2 object like ggVenndiagram().

I actually want to customize the size of the labels of the three graphs, they become too small if the upset plot is too big.

Is it possible then to add two options to control the size of the axis tick labels like the ones already available in the function?

I see there is already an option top.bar.numbers.size, so something like two/three new options top.bar.label.size intersection.matrix.label.size and set.label.size? I guess they would need to be included in the theme functions of upset_plot.