venndir_legender | R Documentation |
Add optional legend to venndir figures (developmental). This function is being evaluated and developed, and will very likely change again in an upcoming release.
venndir_legender(
venndir_output = NULL,
x = "bottomleft",
setlist = NULL,
set_colors = NULL,
unicode = TRUE,
sign_count_delim = NULL,
keep_newlines = FALSE,
legend_total = TRUE,
legend_percentage = NULL,
legend_signed = NULL,
combine_signed = TRUE,
combine_size = TRUE,
legend_color_style = c("fill", "border"),
box.lwd = 0,
legend_style = c("grid", "data.frame"),
item_type = "",
header_color = "#000000",
header_bg = "#FFFFFF00",
header_border = "#FFFFFF00",
lwd = 1,
x_inset = grid::unit(2, "lines"),
y_inset = grid::unit(2, "lines"),
font_cex = 1,
fontfamily = "Arial",
fontfamilies = list(signed = fontfamily, count = fontfamily, overlap = fontfamily),
poly_alpha = 0.8,
table_theme = NULL,
draw_legend = TRUE,
alias = NULL,
labels = NULL,
legend_padding = 3,
set_suffix = "",
vp = NULL,
verbose = FALSE,
...
)
venndir_output |
|
x |
|
setlist |
|
set_colors |
|
unicode |
|
keep_newlines |
|
legend_total |
|
legend_percentage |
|
legend_signed |
|
combine_signed |
|
combine_size |
|
legend_color_style |
|
box.lwd |
|
legend_style |
|
item_type |
|
header_color , header_bg , header_border |
|
lwd |
|
x_inset , y_inset |
|
font_cex |
|
fontfamily |
|
fontfamilies |
|
table_theme |
|
draw_legend |
|
alias |
|
labels |
|
legend_padding |
|
set_suffix |
|
verbose |
|
... |
additional arguments are passed to internal functions.
Notably |
Note this function is experimental and is under active development. The implementation and arguments may change in future.
Limitations: Currently this function relies upon having the setlist
used to produce the venndir()
output, and the venndir()
output.
In future, the setlist
could be derived from the venndir()
output
object directly. That step likely needs a new function.
When using arguments legend_style="grid"
and draw_legend=FALSE
the
grid
grob
object is returned, so that it can be manipulated
as needed before rendering. Note that in this case, the viewport
will have already been defined and stored into legend_grob$vp
with x position legend_grob$vp$x
and y position legend_grob$vp$y
.
Total legend width is: sum(legend_grob$widths)
, and
total legend height is: sum(legend_grob$heights)
.
Todo:
Consider bottom-justifying text in each cell, left-justifying text labels, and right-justifying numeric values.
data.frame
with legend information is returned invisibly,
unless using legend_style="grid", draw_legend=FALSE
in which case the
legend grob
object is returned which can then be manipulated
before rendering.
Other venndir utility:
curate_venn_labels()
,
expand_range()
,
make_color_contrast()
,
make_venn_combn_df()
,
make_venn_test()
,
match_list()
,
modify_venndir_overlap()
,
nudge_venndir_label()
,
plot,Venndir,ANY-method
,
print_color_df()
,
shrink_df()
,
three_point_angle()
,
venndir_to_df()
setlist <- make_venn_test(100, 3, do_signed=TRUE);
# by default the legend is shown
vo <- venndir(setlist)
# move to different corner
vo <- venndir(setlist, legend_x="bottomleft")
# turn off the default legend
vo <- venndir(setlist, draw_legend=FALSE)
venndir_legender(setlist=setlist,
venndir_output=vo,
x="bottomleft")
# test multi-line labels
names(setlist) <- c("Group B-<br>Group A",
"Group C-<br>\nGroup B",
"Group_C-<br>\nGroupA")
vo <- venndir(setlist,
draw_legend=FALSE,
show_segments=FALSE)
venndir_legender(setlist=setlist,
venndir_output=vo,
x="bottomleft")
# Same as above, showing how to render the legend_grob.
# This method also "hides" the column headers.
vo <- venndir(setlist,
show_segments=FALSE,
draw_legend=FALSE,
font_cex=c(1, 1, 0.5, 0.5))
legend_grob <- venndir_legender(setlist=setlist,
venndir_output=vo,
draw_legend=FALSE,
header_color="white",
x="bottomleft")
grid::grid.draw(legend_grob)
# custom grid table theme
vo <- venndir(setlist,
show_segments=FALSE,
draw_legend=FALSE)
legend_grob <- venndir_legender(setlist=setlist,
venndir_output=vo,
headers=FALSE,
x="bottomright",
table_theme=gridExtra::ttheme_default(base_size=11,
base_family="sans",
padding=grid::unit(c(2, 2), "mm")))
# optional expanded labels, and subset setlist
setlist <- make_venn_test(100, 5, do_signed=TRUE);
vo <- venndir(setlist,
sets=c(4, 1, 2),
show_segments=FALSE,
draw_legend=FALSE)
venndir_legender(venndir_output=vo,
font_cex=0.8,
setlist=setlist,
labels=jamba::nameVector(
paste0("This is set ", LETTERS[1:5]),
names(setlist)))
# Venn with no border, and more transparent colors
vo124 <- venndir(setlist, sets=c(1, 2, 4), poly_alpha=0.4, do_plot=FALSE)
vo124@jps@polygons$border.lwd <- 0.1
vo124@jps@polygons$innerborder.lwd <- 0.1
vor124 <- render_venndir(vo124, draw_legend=FALSE)
venndir_legender(setlist=setlist, venndir_output=vo124)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.