4.13 Venndir Graphics Objects
The Venndir
object also stores the grid
graphical objects (grobs)
used for visualization, however the grobs are only created by calling
plot()
or render_venndir()
. The output of this function is Venndir
object with hidden attributes which contain grobs.
When calling venndir()
, two options may be useful:
do_plot=TRUE
: This argument causesvenndir()
to callrender_venndir()
, which then creates the relevant grobs.do_draw=FALSE
: This argument is passed torender_venndir()
, so the grobs are not drawn to the graphical device.
The following example creates a Venndir
object without creating
a new plot, and which creates all the necessary grobs.
v <- venndir(make_venn_test(),
poly_alpha=0.01,
border="black",
border.lwd=2,
show_labels="Ni",
main="Plot Title",
do_plot=TRUE,
do_draw=FALSE,
legend_color_style=c("black", "blackborder"))
The relevant attribute names are described as follows:
'gtree'
: the singlegrid
object that contains all Venndir grobs.'grob_list'
: thelist
of eachgrid
object, separated by type.'viewport'
: thegrid
object representing the graphicsviewport
.'adjx'
,adjy'
: the adjustment function used to convertJamPolygon
coordinates to unit 'nspc' scaled values between 0 and 1.
4.13.1 Venndir gtree
The 'gtree'
attribute contains a grid:gTree
object, which can be
drawn directly. The gtree
object already contains the relevant
viewport
.
Figure 4.25 shows the plot after drawing the 'gtree'
attribute.

Figure 4.25: Venn diagram created by drawing the 'gtree'
attribute object.
A detailed list of all grobs within the gtree
can be seen by calling
grid::grid.ls()
, however it is not listed here because it contains
over 350 grobs!
4.13.2 Venndir grob_list
An alternative representation is the 'grob_list'
attribute,
which is a list
with each Venndir visual component. The exact
elements may vary dependent upon which options were used.
The purpose of inspecting grid
grobs is mainly to allow direct
manipulation of the grobs, for advanced customizations for example.
Each individual component can be edited in detail.
The grobs by type are described below:
'jps'
: theJamPolygon
object with polygons and border.'item_labels'
: item labels, only if enabled by argumentshow_labels
.'labels'
: themarquee
grobs used for all text labels.'segments'
: the line segments connecting labels to polygons, where relevant.'legend'
: thegrid
object representing the Venndir legend, if relevant.'main_title'
: the title object, only if defined by argumentmain
.
Figure 4.26 shows the plot after drawing each grid
component
from the 'grob_list'
attribute.
grob_list <- attr(v, "grob_list");
grid::grid.newpage()
grid::grid.draw(grob_list$jps)
grid::grid.draw(grob_list$item_labels)
grid::grid.draw(grob_list$labels)
grid::grid.draw(grob_list$segments)
grid::grid.draw(grob_list$legend)
grid::grid.draw(grob_list$main_title)

Figure 4.26: Venn diagram created by drawing each component in the 'grob_list'
attribute.