standard +
scale_colour_viridis_b(guide = "colsteps") +
labs(title = "Custom colour steps")
-
+
Please note that the following paragraphs apply equally to
guide_colsteps()
, but we’ll take
guide_colbar()
for examples.
@@ -348,7 +348,7 @@ Caps
limits = c(10, 30),
guide = "colbar"
)
-
+
You can change the out-of-bounds strategy, the oob
argument of the scale, to have the caps reflect the colour that
out-of-bounds data has acquired.
@@ -358,7 +358,7 @@ Caps
limits = c(10, 30), oob = oob_squish,
guide = "colbar"
)
-
+
You can also force the caps to appear, even when there are no
out-of-bounds data, or force the cap colour to be consistent with the
scale.
@@ -370,7 +370,7 @@ Caps
oob = "squish"
)
)
-
+
The shape of the cap needn’t be a triangle. You can set the shape to
any of the built-in cap shapes.
@@ -381,7 +381,7 @@ Caps
shape = "arch"
)
)
-
+
The caps can be provided as a string naming a cap function, like
"arch"
that invokes cap_arch()
. Below follows
an overview of all the build-in cap shapes.
@@ -403,7 +403,7 @@
+
It is most certainly possible to use shapes of your own imagination
as well. To provide your own shape, use a numeric matrix that:
@@ -429,7 +429,7 @@ Caps
shape = hourglass_cap
)
)
-
+
Side-guides
@@ -443,7 +443,7 @@
-
+
This trick allows you to tailor the colour bar to your liking on
separate sides. You can use this to invoke any of the tricks described
in the axis section, like setting minor ticks, or swap out axes for an
@@ -465,7 +465,7 @@
+
Citation
diff --git a/pkgdown.yml b/pkgdown.yml
index 182d88c..a08eff1 100644
--- a/pkgdown.yml
+++ b/pkgdown.yml
@@ -5,7 +5,7 @@ articles:
articles/guide_composition: guide_composition.html
articles/keys: keys.html
articles/tour: tour.html
-last_built: 2024-10-26T10:46Z
+last_built: 2024-10-26T11:00Z
urls:
reference: https://teunbrand.github.io/legendry/reference
article: https://teunbrand.github.io/legendry/articles
diff --git a/search.json b/search.json
index 3cfa743..203be9d 100644
--- a/search.json
+++ b/search.json
@@ -1 +1 @@
-[{"path":"https://teunbrand.github.io/legendry/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 Teun van den Brand Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://teunbrand.github.io/legendry/articles/guide_composition.html","id":"stacking","dir":"Articles","previous_headings":"","what":"Stacking","title":"A guide to guide composition","text":"cut open guide examine innards spilling , eyes first meets skeleton holds guide together. skeleton composition guide: guide whose task render compose guides. composition guide may entirely foreign ggplot2-user. vanilla ggplot2 also contains composition guide, namely guide_axis_stack(). accepts input guide specifications stacks guides top one another. legendry, composition operation: compose_stack(). regular axis guides x y aesthetics, works way guide_axis_stack(). However, guides stacks supports aesthetics, like colour, can also used .","code":"standard <- ggplot(mpg, aes(displ, hwy)) + geom_point() + labs( x = \"Engine displacement (litres)\", y = \"Highway Miles per Gallon\" ) + theme(axis.line = element_line()) standard + guides(x = guide_axis_stack(\"axis\", \"axis\", \"axis\")) staxis <- compose_stack(\"axis_base\", \"axis_base\", \"axis_base\") standard + aes(colour = cty) + guides( x = staxis, colour = guide_colbar(first_guide = staxis, second_guide = \"none\") ) + theme(legend.axis.line = element_line())"},{"path":"https://teunbrand.github.io/legendry/articles/guide_composition.html","id":"primitives","dir":"Articles","previous_headings":"","what":"Primitives","title":"A guide to guide composition","text":"point, might wise take closer look exactly guide_axis_base() . pull threads class , mystery starts unravel: Indeed, using compose_stack(\"axis_base\", \"axis_base\", ...) stacking stack! peel back layers see inside guide_axis_base(), find stacks? : good things must come end must guides building blocks. composition skeleton building blocks flesh providing function. building blocks called ‘primitives’ legendry. example, guide_axis_base() function stack three primitives. respectively build axis line, ticks labels. complete guide, don’t spacing , let’s exaggerate spacing clarity.","code":"class(guide_axis_base()) #> [1] \"ComposeStack\" \"Compose\" \"Guide\" \"ggproto\" \"gg\" standard + guides(x = compose_stack( primitive_line(), primitive_ticks(), primitive_labels(), theme = theme_guide(spacing = unit(5, \"pt\")) ))"},{"path":"https://teunbrand.github.io/legendry/articles/guide_composition.html","id":"introducing-the-rest-of-the-family","dir":"Articles","previous_headings":"Primitives","what":"Introducing the rest of the family","title":"A guide to guide composition","text":"’ve already met ‘famous’ primitives (lines, ticks, labels), let’s round acquaintances. spacer primitive can use increase spacing different pancakes stack, . also ‘ranged’ triplet: brackets, boxes fences. require niche range key power display nested axes. last member family primitive_title(). Aside just displaying text, three things: >1 title, distribute titles along range. makes convenient label lower higher ends scale. ‘absorbs’ regular axis title turning . title primitive guide actual title, makes slightly easier prevent unwanted double titles. implemented guide, take place regular axis titles. also means titles repeat facets.","code":"range_key <- key_range_manual( start = c(2, 4), end = c(5, 6), name = c(\"First\", \"Second\") ) standard + guides(x = compose_stack( \"axis_base\", primitive_bracket(range_key, \"curvy\"), primitive_spacer(unit(0.5, \"cm\")), primitive_box(range_key), primitive_spacer(unit(0.5, \"cm\")), primitive_fence(range_key, rail = \"outer\") )) standard + scale_x_continuous(guide = compose_stack( primitive_title(c( \"Sneaky little displacementses\", \"We needs it. Must have the displament\") ), primitive_title(\"Gollum explains engine displacement to you\") )) + labs(x = \"A normal person explains engine displacement\") last_plot() + facet_grid(~ year)"},{"path":"https://teunbrand.github.io/legendry/articles/guide_composition.html","id":"dont-use-primitives-directly","dir":"Articles","previous_headings":"Primitives","what":"Don’t use primitives directly","title":"A guide to guide composition","text":"giving primitive_-prefix, made impossible use name inside function don’t expect . acts little bit discouragement using primitives complete guides. However, can use primitives name inside guide composition functions, use full constructor function.","code":"standard + guides(x.sec = \"ticks\") #> Error in `validate_guide()`: #> ! Unknown guide: ticks standard + guides(x.sec = compose_stack(\"ticks\")) # Looks identical to the above standard + guides(x.sec = primitive_ticks())"},{"path":"https://teunbrand.github.io/legendry/articles/guide_composition.html","id":"sandwiching","dir":"Articles","previous_headings":"","what":"Sandwiching","title":"A guide to guide composition","text":"Aside making stack primitives, can also build sandwich primitives. Analogous two pieces bread outside good bits inside, sandwich composition guides often sees centrepiece flanked two guides. Similar naively believed guide_axis_stack() little snowflake guide, guide_colbar() fact composition: Focussing ‘bread’ part first, two guides can use flanking innards. One called ‘text’ one called ‘opposite’. called ‘text’ ‘opposite’ ‘text’-guide take position indicated legend.text.position theme element. Perhaps unsurprisingly; guide end called ‘opposite’ guide. can expose swapping theme element. also noted guide label-supression mechanism, ‘opposite’ guide drawn surpressed labels. mechanism place guides like guide_axis()/guide_axis_base() display example facet_grid(axis.labels = \"margins\"). thing guide_colbar() , compose_sandwich() , adjust theme settings match ggplot2::guide_colourbar() closely. Alright, fine, get ‘bread’ part sandwich! inside? ’m glad asked.","code":"class(guide_colbar()) #> [1] \"ComposeSandwich\" \"Compose\" \"Guide\" \"ggproto\" #> [5] \"gg\" standard + aes(colour = cty) + scale_colour_viridis_c( guide = compose_sandwich( text = primitive_labels(), opposite = primitive_ticks() ) ) last_plot() + theme(legend.text.position = \"left\") standard + aes(colour = cty) + scale_colour_viridis_c( guide = compose_sandwich( text = \"axis_base\", opposite = \"axis_base\" ) ) # The same plot standard + aes(colour = cty) + scale_colour_viridis_c( guide = guide_colbar(vanilla = FALSE) )"},{"path":"https://teunbrand.github.io/legendry/articles/guide_composition.html","id":"gizmos","dir":"Articles","previous_headings":"","what":"Gizmos","title":"A guide to guide composition","text":"insides guide_colbar() called ‘gizmo’. gizmo differs primitive gizmo general building block, rather specialised display particular aesthetic. Also, complete guide allow complete crucial task translating graphic display interpretation data. called ‘gizmo’ sort gadget don’t appropriate name . Hence: gizmo.","code":""},{"path":"https://teunbrand.github.io/legendry/articles/guide_composition.html","id":"my-first-gizmo","dir":"Articles","previous_headings":"Gizmos","what":"My first gizmo","title":"A guide to guide composition","text":"can display gizmo guide_colbar() —sandwich spread, — gizmo_barcap(). also immediately clear need bread case. Similarly guide_colsteps() gizmo_stepcap(), might second gizmo may already encountered.","code":"standard + aes(colour = cty) + scale_colour_viridis_c( guide = gizmo_barcap() )"},{"path":"https://teunbrand.github.io/legendry/articles/guide_composition.html","id":"exotic-gizmos","dir":"Articles","previous_headings":"Gizmos","what":"Exotic gizmos","title":"A guide to guide composition","text":"also gizmos may less familiar. reasonably simple one gizmo_grob(), just allows place grob guide. example, can stack axis, use non-bread part sandwich. Please note good representation plot’s colour aesthetic. hope wouldn’t necessary : don’t make plot like ! Perhaps gizmo’s inherently useful gizmo_density() gizmo_histogram(). default, wrap density() hist() functions called layer’s data. can pass arguments functions density.args hist.args respectively. ’ll repeat : gizmos, full guides. Also: please ignore ’re guiding colour fill colour visible. However, can easily promote gizmos full guide adding axis. compose_sandwich() can reasonable job .","code":"my_grob <- grid::grobTree( grid::rectGrob(), grid::textGrob(\"Grob\\nGizmo\") ) my_gizmo <- gizmo_grob(my_grob, width = unit(2, \"cm\"), height = unit(2, \"cm\")) standard + aes(colour = cty) + guides( x = compose_stack(\"axis\", my_gizmo), colour = compose_sandwich(middle = my_gizmo, text = \"axis_base\") ) standard + aes(colour = cty, fill = cty) + scale_colour_viridis_c( option = \"C\", guide = gizmo_density(density.args = list(adjust = 0.7)) ) + scale_fill_viridis_c( option = \"D\", guide = gizmo_histogram(hist.args = list(breaks = 10)) ) standard + aes(colour = cty, fill = cty) + scale_colour_viridis_c( option = \"C\", guide = compose_sandwich( middle = gizmo_density(just = 1), text = \"axis_base\" ) ) + scale_fill_viridis_c( option = \"D\", guide = compose_sandwich( middle = gizmo_histogram(just = 0.5), text = \"axis_base\" ) )"},{"path":"https://teunbrand.github.io/legendry/articles/guide_composition.html","id":"other-compositions","dir":"Articles","previous_headings":"","what":"Other compositions","title":"A guide to guide composition","text":"following compositions situational aren’t part ‘proper’ guide. compose_ontop() guide lets render one guide . can see plots allows us touch panel composing top one another, stacking. also compose_crux() (‘cross’) parent composition compose_sandwich(). Instead allowing bread two sides, can also put guides top bottom. isn’t currently use complete guide though.","code":"top <- guide_axis_base( key = key_manual(32, label = \"Here is 32\"), theme = theme_guide( ticks.length = unit(1.5, \"cm\"), ticks = element_line(arrow = arrow()), line = element_blank() ) ) standard + guides(y.sec = compose_ontop(\"axis\", top)) + labs(title = \"compose_ontop\") standard + guides(y.sec = compose_stack(\"axis\", top)) + labs(title = \"compose_stack\") ball <- gizmo_grob(grid::circleGrob( r = unit(0.5, \"cm\"), gp = grid::gpar(fill = \"tomato\") )) block <- gizmo_grob(grid::rectGrob( width = unit(1, \"cm\"), height = unit(1, \"cm\"), gp = grid::gpar(fill = \"dodgerblue\") )) standard + aes(colour = cty) + scale_colour_viridis_c( guide = compose_crux( centre = gizmo_barcap(), left = \"axis_base\", right = \"axis_base\", top = ball, bottom = block ) )"},{"path":"https://teunbrand.github.io/legendry/articles/keys.html","id":"keys-in-vanilla-ggplot2","dir":"Articles","previous_headings":"","what":"Keys in vanilla ggplot2","title":"Key information","text":"way guides exchange information scales called ‘keys’. Keys simply data frames typically hold information aesthetic, values represent displayed. may already seen keys ’ve used get_guide_data() function , can used retrieved guide’s key. data frame , can see key ‘x’ aesthetic. tells us relative location tick marks aesthetic’s x column, numerical values represent .value column. values communicated users captured .label column. Sometimes, keys information additional aesthetics, like y column key .","code":"standard <- ggplot(mpg, aes(displ, hwy)) + geom_point(aes(shape = drv, colour = drv)) + labs( shape = \"Drive train\", colour = \"Drive train\", y = \"Highway efficiency\", x = \"Engine Displacement\" ) get_guide_data(standard, aesthetic = \"x\") #> x .value .label y #> 1 0.1127946 2 2 0 #> 2 0.2811448 3 3 0 #> 3 0.4494949 4 4 0 #> 4 0.6178451 5 5 0 #> 5 0.7861953 6 6 0 #> 6 0.9545455 7 7 0"},{"path":"https://teunbrand.github.io/legendry/articles/keys.html","id":"keys-in-legendry","dir":"Articles","previous_headings":"","what":"Keys in legendry","title":"Key information","text":"key difference keys legendry keys ggplot2, legendry exposes users keys. first, can inconvenience, allows greater degree customisation.","code":""},{"path":"https://teunbrand.github.io/legendry/articles/keys.html","id":"why-use-keys","dir":"Articles","previous_headings":"Keys in legendry","what":"Why use keys?","title":"Key information","text":"dig different types keys, worth noting exactly keys exposed. Keys represent ‘rules’ annotate scale, whereas guide display rule. example, key_log() instructs annotate every 10x change large ticks, changes smaller ticks. doesn’t really matter whether rule applied axis colour bar. rule independent display makes modular.","code":"logkey <- key_log() ggplot(msleep, aes(sleep_total, brainwt, colour = bodywt)) + geom_point(na.rm = TRUE) + scale_y_log10(guide = guide_axis_base(key = logkey)) + scale_colour_viridis_c( trans = \"log10\", guide = guide_colbar(key = logkey) )"},{"path":"https://teunbrand.github.io/legendry/articles/keys.html","id":"regular-keys","dir":"Articles","previous_headings":"Keys in legendry","what":"Regular keys","title":"Key information","text":"understand better typical key works, can use key_manual() manually create key. Usually sufficient just provide aesthetic argument, .value .label columns automatically derive . want custom labels, can set label argument. guides legendry accept key argument, cause guide display information key, rather information automatically derived scale. addition, can provide automatic keys keywords. Setting key = \"minor\", setting key = key_minor(). fashion many key_*() functions can used keyword omitting key_-prefix. keys don’t directly return data frames, return instructions keys interact scales. example key_auto(), default key many guides legendry, needs know range populate tickmarks. can preview values ’d label letting key absorb scale known limits.","code":"key_manual(aesthetic = c(2, 4, 6)) #> aesthetic .value .label #> 1 2 2 2 #> 2 4 4 4 #> 3 6 6 6 my_key <- key_manual(aesthetic = c(2, 4, 6), label = c(\"two\", \"four\", \"six\")) standard + guides(x = guide_axis_base(key = my_key)) standard + guides(x = guide_axis_base(key = \"minor\")) key <- key_auto() print(key) #> function (scale, aesthetic = NULL) #> { #> aesthetic <- aesthetic %||% scale$aesthetics[1] #> df <- Guide$extract_key(scale, aesthetic) #> df <- data_frame0(df, !!!label_args(...)) #> class(df) <- c(\"key_standard\", \"key_guide\", class(df)) #> df #> } #> #> template <- scale_y_log10(limits = c(1, 1000)) key(template, \"y\") #> y .value .label #> 1 0 0 1 #> 2 1 1 10 #> 3 2 2 100 #> 4 3 3 1000"},{"path":"https://teunbrand.github.io/legendry/articles/keys.html","id":"ranged-keys","dir":"Articles","previous_headings":"Keys in legendry","what":"Ranged keys","title":"Key information","text":"special type guide may find legendry called ‘ranged’ guides. difference regular guides mark single point aesthetic, rather use start- end-point mark range aesthetic. can convenient annotate co-occurrances data plotting events. example, can annotate airtimes TV shows timeseries data. Compared regular key, don’t aesthetic column, replaced start end columns. cases, indicate single .value, can still use .label column. .level column indicates far offset range, ’ll display “Frasier” farther away “Golden Girls”. also ‘automatic’ ranged key, attempts find patterns key labels. example obvious pattern x-axis labels plot first 3 entries 3 drive trains 1999, followed 3 drive trains 2008. default, key_range_auto() tries split label non-alphanumeric character, give explicit split instructions using sep argument.","code":"ranges <- key_range_manual( start = as.Date(c(\"1985-09-14\", \"1993-09-16\")), end = as.Date(c(\"1992-05-09\", \"2004-05-13\")), name = c(\"Golden Girls\", \"Frasier\"), level = 1:2 ) ranges #> start end .label .level #> 1 1985-09-14 1992-05-09 Golden Girls 1 #> 2 1993-09-16 2004-05-13 Frasier 2 ggplot(economics, aes(date, unemploy)) + geom_line() + guides(x.sec = primitive_bracket(ranges)) plot <- ggplot(mpg, aes(interaction(drv, year), displ, fill = drv)) + geom_boxplot() + labs( x = \"Drive train by year\", y = \"Engine displacement\", fill = \"Drive train\" ) plot # Split on literal periods key <- key_range_auto(sep = \"\\\\.\") plot + guides(x = primitive_bracket(key = key))"},{"path":[]},{"path":"https://teunbrand.github.io/legendry/articles/keys.html","id":"piping-keys","dir":"Articles","previous_headings":"Futher gimmicks","what":"Piping keys","title":"Key information","text":"key_manual() key_range_manual() functions equivalents easy pipe. called key_map() key_range_map() respectively, can replace following: following, pipe-friendly version: keys display something like :","code":"key <- key_range_manual( start = presidential$start, end = presidential$end, name = presidential$name ) key <- presidential |> key_range_map( start = start, end = end, name = name ) ggplot(economics, aes(date, unemploy)) + geom_line() + guides(x.sec = primitive_bracket(key))"},{"path":"https://teunbrand.github.io/legendry/articles/keys.html","id":"formatting-keys","dir":"Articles","previous_headings":"Futher gimmicks","what":"Formatting keys","title":"Key information","text":"addition lot control keys display, also control common text formatting operations keys. key options ... argument allows many arguments element_text() passed labels. cases know label advance, almost every time one uses key_manual(), key_map() ranged equivalents, can even vectorise formatting options.","code":"ggplot(mpg, aes(displ, hwy)) + geom_point() + guides(x = guide_axis_base(key = key_auto(colour = \"red\", face = \"bold\"))) guide <- presidential |> key_range_map( start = start, end = end, name = name, colour = ifelse(party == \"Republican\", \"tomato\", \"dodgerblue\"), face = \"bold\" ) |> primitive_bracket() ggplot(economics, aes(date, unemploy)) + geom_line() + guides(x.sec = guide)"},{"path":"https://teunbrand.github.io/legendry/articles/keys.html","id":"forbidden-keys","dir":"Articles","previous_headings":"Futher gimmicks","what":"Forbidden keys","title":"Key information","text":", time writing, two keys probably shouldn’t use code. key_sequence() key_bins(). hope mentioning use prevent experimenting subsequent frustration keys. can see key_sequence() produce informative axis. reason key designed colour gradients Likewise, key_bins() designed regular guides, specific colour steps.","code":"my_sequence_key <- key_sequence(n = 20) standard + guides(x = guide_axis_base(key = my_sequence_key)) ggplot(mpg, aes(displ, hwy, colour = cty)) + geom_point() + scale_colour_viridis_c( guide = gizmo_barcap(key = my_sequence_key) ) my_bins_key <- key_bins() ggplot(mpg, aes(displ, hwy, colour = cty)) + geom_point() + scale_colour_viridis_c( guide = gizmo_stepcap(key = my_bins_key) )"},{"path":"https://teunbrand.github.io/legendry/articles/tour.html","id":"axes","dir":"Articles","previous_headings":"","what":"Axes","title":"A guided tour","text":"Axes truly bread butter guides. Naturally, axes shine brightest guides positions like x y can moonlight auxiliary guides well.","code":""},{"path":"https://teunbrand.github.io/legendry/articles/tour.html","id":"where-not-to-apply","dir":"Articles","previous_headings":"Axes","what":"Where (not) to apply","title":"A guided tour","text":"legendry, staple axis guide_axis_base(). first glance, axes utterly unremarkable much mirror ggplot2::guide_axis() design. terms novelty, ‘extra’ option axes offer display bidirectional tick marks. However, guide_axis_base() flexible ggplot2::guide_axis(). ggplot2, ’d typically switch ggplot2::guide_axis_theta() display axis theta coordinate polar plot. custom axis knows fit polar coordinates, fuss needed switching polar coordinates. Argueably, custom guide little bit flexible. exactly scruples displaying arbitrary continuous aesthetics, like colour plot . can see, informative colour guide reason ’d advice . unadvised yet possible topic resurfaces later article. summary, guide_axis_base() flexible guide can used position aesthetic, can () used continuous aesthetics.","code":"# Turn on axis lines theme_update(axis.line = element_line()) # A standard plot standard <- ggplot(mpg, aes(displ, hwy)) + geom_point() + labs( x = \"Engine Displacement (Litres)\", y = \"Highway Miles per Gallon\" ) standard + guides( x = \"axis_base\", y = \"axis_base\" ) p <- standard + scale_x_continuous(guide = guide_axis_base(bidi = TRUE)) + scale_y_continuous(guide = guide_axis_base(bidi = TRUE)) p p + coord_radial(start = 1.25 * pi, end = 2.75 * pi) standard + aes(colour = cty) + guides(colour = \"axis_base\")"},{"path":"https://teunbrand.github.io/legendry/articles/tour.html","id":"nested-axes","dir":"Articles","previous_headings":"Axes","what":"Nested axes","title":"A guided tour","text":"Currently, exactly 1 ‘novelty’ axis guide_axis_nested(). Let’s suppose ‘nested’ data, purposes just means discrete variables kind categories interactions can laid nested fashion. category categories, . example three super-categories ‘Drink’, ‘Fruit’ ‘Vehicle’ granular categories like ‘Coffee’ ‘Pear’ belong super-categories. can use interaction() function paste together name inner category name outer category. Instead just relying formatting labels correctly splitting, can also manually annotate outer categories. , can use key_range_manual() function constructs brackets see fit.","code":"df <- data.frame( item = c(\"Coffee\", \"Tea\", \"Apple\", \"Pear\", \"Car\"), type = c(\"Drink\", \"Drink\", \"Fruit\", \"Fruit\", \"Vehicle\"), amount = c(5, 1, 2, 3, 1) ) plain <- ggplot(df, aes(interaction(item, type), amount)) + geom_col() plain + guides(x = \"axis_nested\") my_key <- key_range_manual( start = c(\"Coffee\", \"Apple\"), end = c(\"Tea\", \"Pear\"), name = c(\"Drinks\", \"Fruits\"), level = 1 ) ggplot(df, aes(item, amount)) + geom_col() + scale_x_discrete( limits = df$item, guide = guide_axis_nested( regular_key = \"auto\", key = my_key ) )"},{"path":"https://teunbrand.github.io/legendry/articles/tour.html","id":"brackets","dir":"Articles","previous_headings":"Axes > Nested axes","what":"Brackets","title":"A guided tour","text":"change style range indicators, can choose different bracket setting. theme elements legendry.bracket legendry.bracket.size control styling size line. settings shortcut theme_guide(). brackets can provided string naming bracket function, like \"curvy\" invokes bracket_curvy(). follows overview build-bracket shapes. Quite possibly, might bracket shapes want use, aren’t built legendry. Luckily, can build custom brackets, using numeric matrix : 2 columns corresponding x y coordinates. least 2 rows. values 0 1. x-coordinate stretched along axis, whereas y squished fit legendry.bracket.size theme setting. custom bracket can just provided bracket argument.","code":"plain + guides(x = guide_axis_nested(bracket = \"curvy\")) + theme_guide( bracket = element_line(colour = \"blue\"), bracket.size = unit(3, \"mm\") ) brackets <- list( \"atan\" = bracket_atan(), \"chevron\" = bracket_chevron(), \"curvy\" = bracket_curvy(), \"line\" = bracket_line(), \"round\" = bracket_round(), \"sigmoid\" = bracket_sigmoid(), \"square\" = bracket_square() ) brackets <- cbind( as.data.frame(do.call(rbind, brackets)), shape = factor(rep(names(brackets), lengths(brackets) / 2), names(brackets)) ) ggplot(brackets, aes(x, y)) + geom_path() + facet_wrap(~ shape) + coord_equal() zigzag <- cbind( x = seq(0, 1, length.out = 20), y = rep(c(0, 1), length.out = 20) ) plain + guides(x = guide_axis_nested(bracket = zigzag))"},{"path":"https://teunbrand.github.io/legendry/articles/tour.html","id":"boxes","dir":"Articles","previous_headings":"Axes > Nested axes","what":"Boxes","title":"A guided tour","text":"Alternatively, also possible forego brackets altogether use boxes instead.","code":"plain + guides(x = guide_axis_nested(type = \"box\"))"},{"path":"https://teunbrand.github.io/legendry/articles/tour.html","id":"customising","dir":"Articles","previous_headings":"Axes > Nested axes","what":"Customising","title":"A guided tour","text":"needn’t strictly use guide_axis_nested() discrete data: can use continuous data well. However, ’d need provide manual ranged key, one created key_range_manual()/key_range_map(). customise different depths bracketed text, can give list text elements levels_text argument. Alternatively, can tailor many usual text formatting options encoding key.","code":"presidents <- key_range_map(presidential, start = start, end = end, name = name) eco <- ggplot(economics, aes(date, unemploy)) + geom_line() + labs(y = \"Unemployment\") eco + guides(x = guide_axis_nested(key = presidents)) presidents$.level <- rep(1:3, length.out = nrow(presidents)) eco + guides(x = guide_axis_nested( key = presidents, levels_text = list( element_text(face = \"bold\"), NULL, element_text(face = \"italic\") ) )) presidents <- key_range_map( presidential, start = start, end = end, name = name, level = rep(1:4, length.out = nrow(presidential)), colour = ifelse(party == \"Republican\", \"tomato\", \"dodgerblue\") ) eco + guides(x = guide_axis_nested(key = presidents))"},{"path":"https://teunbrand.github.io/legendry/articles/tour.html","id":"colours","dir":"Articles","previous_headings":"","what":"Colours","title":"A guided tour","text":"colour fill aesthetics wonderful build guides , can apply pretty much anything. First, ’ll take gander variants colour bars gander rings.","code":""},{"path":"https://teunbrand.github.io/legendry/articles/tour.html","id":"bars-and-steps","dir":"Articles","previous_headings":"Colours","what":"Bars and steps","title":"A guided tour","text":"Two variants colour guides exist {legendry}: guide_colbar() reflects guide_colourbar() guide_colsteps() reflects guide_coloursteps(). used standard fashion, look similar vanilla counterparts. Please note following paragraphs apply equally guide_colsteps(), ’ll take guide_colbar() examples.","code":"standard <- standard + aes(colour = cty) + labs(colour = \"City Miles\\nper Gallon\") standard + scale_colour_viridis_c(guide = \"colbar\") + labs(title = \"Custom colour bar\") standard + scale_colour_viridis_b(guide = \"colsteps\") + labs(title = \"Custom colour steps\")"},{"path":"https://teunbrand.github.io/legendry/articles/tour.html","id":"caps","dir":"Articles","previous_headings":"Colours > Bars and steps","what":"Caps","title":"A guided tour","text":"thing sets guides apart indicators data goes --bounds. common case --bounds data, set scale limits narrower data range. plot , cty variable observation lower limit 10, upper limit 30. Typically, displayed na.value = \"grey\" colour. bars display data --bounds gray ‘caps’ two ends bar. can change --bounds strategy, oob argument scale, caps reflect colour --bounds data acquired. can also force caps appear, even --bounds data, force cap colour consistent scale. shape cap needn’t triangle. can set shape built-cap shapes. caps can provided string naming cap function, like \"arch\" invokes cap_arch(). follows overview build-cap shapes. certainly possible use shapes imagination well. provide shape, use numeric matrix : 2 columns corresponding x y coordinates. least 2 rows. positive values 2nd column (y). Start (0, 0) coordinate. End (1, 0) coordinate. can see shapes requirements hold built-shapes. matrix can given shape argument guide.","code":"standard + scale_colour_viridis_c( limits = c(10, 30), guide = \"colbar\" ) standard + scale_colour_viridis_c( limits = c(10, 30), oob = oob_squish, guide = \"colbar\" ) standard + scale_colour_viridis_c( guide = guide_colbar( show = c(FALSE, TRUE), oob = \"squish\" ) ) standard + scale_colour_viridis_c( guide = guide_colbar( show = TRUE, oob = \"squish\", shape = \"arch\" ) ) caps <- list( none = cap_none(), triangle = cap_triangle(), round = cap_round(), arch = cap_arch(), ogee = cap_ogee() ) caps <- cbind( as.data.frame(do.call(rbind, caps)), shape = factor(rep(names(caps), lengths(caps) / 2), names(caps)) ) ggplot(caps, aes(x, y)) + geom_path(arrow = arrow()) + facet_wrap(~ shape) + coord_equal() hourglass_cap <- cbind( x = c(0, 1, 0, 1), y = c(0, 1, 1, 0) ) standard + scale_colour_viridis_c( guide = guide_colbar( show = TRUE, oob = \"squish\", shape = hourglass_cap ) )"},{"path":"https://teunbrand.github.io/legendry/articles/tour.html","id":"side-guides","dir":"Articles","previous_headings":"Colours > Bars and steps","what":"Side-guides","title":"A guided tour","text":"colour bars come small party trick: two rows tick marks separate axes masquerading parts colour bar. becomes easier see wash away make-vanilla = FALSE. trick allows tailor colour bar liking separate sides. can use invoke tricks described axis section, like setting minor ticks, swap axes annotation-primitive like primitive_bracket().","code":"standard + scale_colour_viridis_c( guide = guide_colbar(vanilla = FALSE) ) brackets <- key_range_manual( start = c(9, 25), end = c(19, 30), name = c(\"A\", \"B\") ) |> primitive_bracket(bracket = \"square\") standard + scale_colour_viridis_c( minor_breaks = breaks_width(1), guide = guide_colbar( first_guide = guide_axis_base(\"minor\"), second_guide = brackets ) )"},{"path":"https://teunbrand.github.io/legendry/articles/tour.html","id":"rings","dir":"Articles","previous_headings":"Colours","what":"Rings","title":"A guided tour","text":"Aside bars steps, also option show colour ring. understand might convenient, can help understand type data suitable . prime example cyclical data can month year. time December January just one month, encoded numerically, difference 11 months. problem can show sometimes periodic data, like housing sales . Every year get sharp colour transition winter. remedy problem use cyclical palette. {scico} package offers suitable cyclical palettes, like ‘romaO’, ‘vikO’, ‘bamO’, ‘corkO’ ‘brocO’. already much better, guide poor job displaying cyclical nature months. better reflected guide, can use guide_colring(). ‘thickness’ donut can controlled legend.key.width parameter, default 1/5th diameter. outer diameter ring controlled legend.key.size parameter, multiplied 5 consistency colour bar multiplier. Like custom colour bars, possible set custom guides, hoarded inner_guide outer_guide distinguish aren’t first second.","code":"housing <- ggplot( subset(txhousing, city == \"Houston\"), aes(date, volume, colour = month) ) + geom_line() + scale_y_continuous( name = \"Total volume of sales\", labels = dollar_format(scale = 1e-6, suffix = \"M\") ) + labs( x = \"Date\", colour = \"Month\" ) housing + scale_colour_viridis_c(limits = c(0, 12)) # Colours from scico::scico(12, palette = \"romaO\") periodic_pal <- c(\"#723957\", \"#843D3A\", \"#97552B\", \"#B08033\", \"#CBB45D\", \"#D5DA99\", \"#B8DEC3\", \"#85C7CF\", \"#599FC4\", \"#4E73AB\", \"#5F4C81\", \"#723959\") housing + scale_colour_gradientn(colours = periodic_pal, limits = c(0, 12)) housing + scale_colour_gradientn( colours = periodic_pal, limits = c(1, 13), breaks = 1:12, guide = \"colring\" ) housing + scale_colour_gradientn( colours = periodic_pal, limits = c(1, 13), breaks = 1:12, minor_breaks = breaks_width(0.25), guide = guide_colring( outer_guide = guide_axis_base(\"minor\"), inner_guide = \"none\" ) ) + theme( legend.key.width = rel(2.5), # fill to center legend.key.size = unit(0.5, \"cm\") # actual size is 0.5 * 5 = 2.5 cm )"},{"path":"https://teunbrand.github.io/legendry/articles/tour.html","id":"legends","dir":"Articles","previous_headings":"","what":"Legends","title":"A guided tour","text":"Well ’d implemented first something tell. continued find time writing .","code":""},{"path":"https://teunbrand.github.io/legendry/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Teun van den Brand. Author, maintainer.","code":""},{"path":"https://teunbrand.github.io/legendry/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"van den Brand T (2024). legendry: Extended guide options 'ggplot2'. R package version 0.0.0.9001, https://github.com/teunbrand/legendry, https://teunbrand.github.io/legendry/.","code":"@Manual{, title = {legendry: Extended guide options for 'ggplot2'}, author = {Teun {van den Brand}}, year = {2024}, note = {R package version 0.0.0.9001, https://github.com/teunbrand/legendry}, url = {https://teunbrand.github.io/legendry/}, }"},{"path":"https://teunbrand.github.io/legendry/index.html","id":"legendry-","dir":"","previous_headings":"","what":"Extended guide options for ggplot2","title":"Extended guide options for ggplot2","text":"goal legendry provide additional guide functionality ggplot2 ecosystem.","code":""},{"path":"https://teunbrand.github.io/legendry/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Extended guide options for ggplot2","text":"can install development version legendry GitHub :","code":"# install.packages(\"devtools\") devtools::install_github(\"teunbrand/legendry\")"},{"path":"https://teunbrand.github.io/legendry/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Extended guide options for ggplot2","text":"Let’s first set basic plot experiment : legendry package offers selection calls ‘complete guides’. complete guides can just drop-replacement regular guides, can specify using ggplot2’s guides() function using guide argument scales. example , ’re using two custom variants vanilla guides, namely guide_axis_base() guide_colbar(). custom variants additional options allow greater degree customisation: axis guide option bidirectional ticks. colourbar automatically recognises --bounds values displays cap. Besides complete guides, legendry also incomplete guides can composed. ggplot2::guide_axis_stack() axis composition function can used display multiple guides. , use ‘primitive’ guide (incomplete building block) display range axis. stacking regular axis primitive guide completed. legendry package extends guide composition concept beyond axes types guides. example compose ‘sandwich’: central guide flanked two others. bracket primitive, matter aesthetic displays can re-use sandwich. ’ve yet write vignette composition.","code":"library(legendry) #> Loading required package: ggplot2 base <- ggplot(mpg, aes(displ, hwy, colour = cty)) + geom_point() + labs( x = \"Engine displacement\", y = \"Highway miles per gallon\", col = \"City miles\\nper gallon\" ) + theme(axis.line = element_line()) base + scale_colour_viridis_c( limits = c(NA, 30), guide = \"colbar\" ) + guides( x = guide_axis_base(bidi = TRUE) ) # A partial guide to display a bracket efficient_bracket <- primitive_bracket( # Keys determine what is displayed key = key_range_manual(start = 25, end = Inf, name = \"Efficient\"), bracket = \"square\", # We want vertical text theme = theme( legend.text = element_text(angle = 90, hjust = 0.5), axis.text.y.left = element_text(angle = 90, hjust = 0.5) ) ) base + guides(y = guide_axis_stack(\"axis\", efficient_bracket)) base + scale_colour_viridis_c( guide = compose_sandwich( middle = gizmo_density(), text = \"axis_base\", opposite = efficient_bracket ) )"},{"path":"https://teunbrand.github.io/legendry/reference/bracket_options.html","id":null,"dir":"Reference","previous_headings":"","what":"Bracket options — bracket_options","title":"Bracket options — bracket_options","text":"functions construct various sorts brackets. construct matrix can supplied bracket argument primitive_bracket().","code":""},{"path":"https://teunbrand.github.io/legendry/reference/bracket_options.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bracket options — bracket_options","text":"","code":"bracket_line() bracket_square() bracket_chevron() bracket_round(angle = 180, n = 100) bracket_sigmoid(curvature = 10, n = 100) bracket_atan(curvature = 5, n = 100) bracket_curvy(angle = 225, n = 100)"},{"path":"https://teunbrand.github.io/legendry/reference/bracket_options.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bracket options — bracket_options","text":"angle numeric(1): angle degrees circle piece drawn. bracket_curvy(), angle 180 270. n integer(1) number points use bracket. curvature numeric(1) controls curliness bracket. precisely, used construct sequence seq(-curvature, curvature, length.= n) logistic arctangent functions evaluated.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/bracket_options.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bracket options — bracket_options","text":" coordinates points brackets.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/bracket_options.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Bracket options — bracket_options","text":"designing custom bracket shapes, expectation columns number 0 1. first column follows direction guide whereas second column orthogonal direction.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/bracket_options.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Bracket options — bracket_options","text":"bracket_line(): simple line bracket. n = 2 points. bracket_square(): square bracket. n = 4 points. bracket_chevron(): chevron (V-shape) makes bracket. n = 3 points. bracket_round(): One circular arc makes bracket. bracket_sigmoid(): Two sigmoid curves stacked top one another form bracket. bracket_atan(): Two arctangent curves stacked top one another form bracket. bracket_curvy(): Four circular arcs make bracket.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/bracket_options.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Bracket options — bracket_options","text":"","code":"plot(bracket_sigmoid(), type = 'l')"},{"path":"https://teunbrand.github.io/legendry/reference/cap_options.html","id":null,"dir":"Reference","previous_headings":"","what":"Cap options — cap_options","title":"Cap options — cap_options","text":"functions construct various sorts caps. construct matrix can supplied shape argument gizmo_barcap().","code":""},{"path":"https://teunbrand.github.io/legendry/reference/cap_options.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cap options — cap_options","text":"","code":"cap_triangle() cap_round(n = 100) cap_arch(n = 100) cap_ogee(n = 100) cap_none()"},{"path":"https://teunbrand.github.io/legendry/reference/cap_options.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cap options — cap_options","text":"n number points use cap.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/cap_options.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cap options — cap_options","text":" coordinates points brackets.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/cap_options.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Cap options — cap_options","text":"designing custom cap shapes, expectation first point starts (0, 0) coordinate last point ends (0, 1) coordinate. first column follows orthogonal direction bar whereas second column follows direction bar.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/cap_options.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Cap options — cap_options","text":"cap_triangle(): equilateral triangle n = 3 points. cap_round(): semicircle. cap_arch(): Two circular arcs forming equilateral Gothic arch. cap_ogee(): Four circular arcs forming 'ogee' arch. cap_none(): cap.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/cap_options.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cap options — cap_options","text":"","code":"plot(cap_arch(), type = 'l')"},{"path":"https://teunbrand.github.io/legendry/reference/common_parameters.html","id":null,"dir":"Reference","previous_headings":"","what":"common parameters in legendry — common_parameters","title":"common parameters in legendry — common_parameters","text":"collection common parameters needn't re-documented time.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/common_parameters.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"common parameters in legendry — common_parameters","text":"title indicating title guide. NULL, title shown. default, waiver(), takes name scale object name specified labs() title. theme object style guide individually differently plot's theme settings. theme argument guide overrides combined plot's theme. position giving location guide. Can one \"top\", \"bottom\", \"left\" \"right\". order positive specifies order guide among multiple guides. controls order guides merged multiple guides position. 0 (default), order determined hashing indicative settings guide. available_aes vector listing aesthetics guide can build. direction indicating direction guide. Can \"horizontal\" \"vertical\". angle specification text angle. Compared setting angle argument element_text(), argument uses heuristics automatically pick hjust vjust probably want. Can one following: NULL take angles justification settings directly theme. waiver() allow reasonable defaults special cases. -360 360 text angle degrees. override.aes named specifying aesthetic parameters key glyphs. See details examples guide_legend().","code":""},{"path":"https://teunbrand.github.io/legendry/reference/compose_crux.html","id":null,"dir":"Reference","previous_headings":"","what":"Compose guides in a cross — compose_crux","title":"Compose guides in a cross — compose_crux","text":"guide composition central guide optionally surrounded guides four sides.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/compose_crux.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compose guides in a cross — compose_crux","text":"","code":"compose_crux( key = NULL, centre = \"none\", left = \"none\", right = \"none\", top = \"none\", bottom = \"none\", args = list(), complete = FALSE, theme = NULL, theme_defaults = list(), reverse = FALSE, order = 0, title = waiver(), position = waiver(), available_aes = NULL )"},{"path":"https://teunbrand.github.io/legendry/reference/compose_crux.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compose guides in a cross — compose_crux","text":"key standard key specification. key shared among guides NULL keys . See information linked topic. centre, left, right, top, bottom Guides use composition per position. guide can specified one following: class object. returns class object. naming function, without guide_ primitive_ prefix. args arguments pass guides given either function string. complete whether treat composition complete guide. TRUE, title margin added result. FALSE (default), titles margins added. theme object style guide individually differently plot's theme settings. theme arguments guide overrides, combined , plot's theme. theme_defaults theme elements override undeclared theme arguments. reverse whether reverse continuous guides. TRUE, guides like colour bars flipped. FALSE (default), original order maintained. order positive specifies order guide among multiple guides. controls order guides merged multiple guides position. 0 (default), order determined hashing indicative settings guide. title indicating title guide. NULL, title shown. default, waiver(), takes name scale object name specified labs() title. position guide drawn: one \"top\", \"bottom\", \"left\", \"right\". available_aes vector listing aesthetics guide can build.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/compose_crux.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compose guides in a cross — compose_crux","text":" guide object.","code":""},{"path":[]},{"path":"https://teunbrand.github.io/legendry/reference/compose_crux.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compose guides in a cross — compose_crux","text":"","code":"NULL #> NULL"},{"path":"https://teunbrand.github.io/legendry/reference/compose_ontop.html","id":null,"dir":"Reference","previous_headings":"","what":"Compose guides on top of one another — compose_ontop","title":"Compose guides on top of one another — compose_ontop","text":"guide can place place guides top one another.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/compose_ontop.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compose guides on top of one another — compose_ontop","text":"","code":"compose_ontop( ..., args = list(), key = NULL, title = waiver(), angle = waiver(), theme = NULL, order = 0, position = waiver(), available_aes = NULL )"},{"path":"https://teunbrand.github.io/legendry/reference/compose_ontop.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compose guides on top of one another — compose_ontop","text":"... Guides stack composition. guide can specified one following: class object. returns class object. naming function, without guide_ primitive_ prefix. args arguments pass guides given either function string. key standard key specification. key shared among guides NULL keys . See information linked topic. title indicating title guide. NULL, title shown. default, waiver(), takes name scale object name specified labs() title. angle specification text angle. Compared setting angle argument element_text(), argument uses heuristics automatically pick hjust vjust probably want. Can one following: NULL take angles justification settings directly theme. waiver() allow reasonable defaults special cases. -360 360 text angle degrees. theme object style guide individually differently plot's theme settings. theme argument guide overrides combined plot's theme. order positive specifies order guide among multiple guides. controls order guides merged multiple guides position. 0 (default), order determined hashing indicative settings guide. position giving location guide. Can one \"top\", \"bottom\", \"left\" \"right\". available_aes giving aesthetics must match guides.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/compose_ontop.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compose guides on top of one another — compose_ontop","text":" composite guide object.","code":""},{"path":[]},{"path":"https://teunbrand.github.io/legendry/reference/compose_ontop.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compose guides on top of one another — compose_ontop","text":"","code":"# Using the ontop composition to get two types of ticks with different # lengths ggplot(mpg, aes(displ, hwy)) + geom_point() + guides(x = compose_ontop( guide_axis_base( key_manual(c(2, 4, 6)), theme = theme( axis.ticks = element_line(colour = \"limegreen\"), axis.ticks.length = unit(11, \"pt\") ) ), guide_axis_base( key_manual(c(3, 5, 7)), theme = theme( axis.ticks = element_line(colour = \"tomato\"), axis.ticks.length = unit(5.5, \"pt\") ) ) ))"},{"path":"https://teunbrand.github.io/legendry/reference/compose_sandwich.html","id":null,"dir":"Reference","previous_headings":"","what":"Compose guides as a sandwich — compose_sandwich","title":"Compose guides as a sandwich — compose_sandwich","text":"guide composition middle guide flanked two parallel guides.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/compose_sandwich.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compose guides as a sandwich — compose_sandwich","text":"","code":"compose_sandwich( key = key_auto(), middle = gizmo_barcap(), text = \"none\", opposite = \"none\", args = list(), complete = TRUE, theme = NULL, theme_defaults = list(), reverse = FALSE, order = 0, title = waiver(), position = waiver(), available_aes = NULL )"},{"path":"https://teunbrand.github.io/legendry/reference/compose_sandwich.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compose guides as a sandwich — compose_sandwich","text":"key standard key specification. key shared among guides NULL keys . See information linked topic. middle Guide use middle guide. guide can specified one following: class object. returns class object. naming function, without guide_ primitive_ prefix. text, opposite Guides use legend.text.position location opposite side middle guide respectively. Guide specification middle argument. args arguments pass guides given either function string. complete whether treat composition complete guide. TRUE, title margin added result. FALSE (default), titles margins added. theme object style guide individually differently plot's theme settings. theme arguments guide overrides, combined , plot's theme. theme_defaults theme elements override undeclared theme arguments. reverse whether reverse continuous guides. TRUE, guides like colour bars flipped. FALSE (default), original order maintained. order positive specifies order guide among multiple guides. controls order guides merged multiple guides position. 0 (default), order determined hashing indicative settings guide. title indicating title guide. NULL, title shown. default, waiver(), takes name scale object name specified labs() title. position guide drawn: one \"top\", \"bottom\", \"left\", \"right\". available_aes vector listing aesthetics guide can build.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/compose_sandwich.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compose guides as a sandwich — compose_sandwich","text":" guide object.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/compose_sandwich.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Compose guides as a sandwich — compose_sandwich","text":"sandwich composition effectively crux composition lacking two opposing arms.","code":""},{"path":[]},{"path":"https://teunbrand.github.io/legendry/reference/compose_sandwich.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compose guides as a sandwich — compose_sandwich","text":"","code":"# A standard plot with a sandwich guide ggplot(mpg, aes(displ, hwy)) + geom_point(aes(colour = cty)) + guides(colour = compose_sandwich( middle = \"colourbar\", text = \"axis_base\", opposite = primitive_bracket(key = key_range_manual( start = c(10, 20), end = c(25, 30), name = c(\"A\", \"B\") )) ))"},{"path":"https://teunbrand.github.io/legendry/reference/compose_stack.html","id":null,"dir":"Reference","previous_headings":"","what":"Compose guides as stack — compose_stack","title":"Compose guides as stack — compose_stack","text":"guide can stack guides.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/compose_stack.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compose guides as stack — compose_stack","text":"","code":"compose_stack( ..., args = list(), key = NULL, title = waiver(), side.titles = waiver(), angle = waiver(), theme = NULL, order = 0, drop = NULL, position = waiver(), available_aes = NULL )"},{"path":"https://teunbrand.github.io/legendry/reference/compose_stack.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compose guides as stack — compose_stack","text":"... Guides stack composition. guide can specified one following: class object. returns class object. naming function, without guide_ primitive_ prefix. args arguments pass guides given either function string. key standard key specification. key shared among guides NULL keys . See information linked topic. title indicating title guide. NULL, title shown. default, waiver(), takes name scale object name specified labs() title. side.titles giving labels titles displayed side stack. Set NULL display side titles. waiver(), attempt made extract titles guides use side titles. angle specification text angle. Compared setting angle argument element_text(), argument uses heuristics automatically pick hjust vjust probably want. Can one following: NULL take angles justification settings directly theme. waiver() allow reasonable defaults special cases. -360 360 text angle degrees. theme object style guide individually differently plot's theme settings. theme argument guide overrides combined plot's theme. order positive specifies order guide among multiple guides. controls order guides merged multiple guides position. 0 (default), order determined hashing indicative settings guide. drop giving indices guides dropped facet requests labels drawn axes panels. default, NULL, drop every guide except first. position giving location guide. Can one \"top\", \"bottom\", \"left\" \"right\". available_aes giving aesthetics must match guides.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/compose_stack.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compose guides as stack — compose_stack","text":" guide object.","code":""},{"path":[]},{"path":"https://teunbrand.github.io/legendry/reference/compose_stack.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compose guides as stack — compose_stack","text":"","code":"ggplot() + geom_function(fun = dnorm, xlim = c(-3, 3)) + guides(x = compose_stack( \"axis\", \"axis\", side.titles = c(\"first\", \"second\") )) + # Add margin to make room for side titles theme(plot.margin = margin(5.5, 5.5, 5.5, 11))"},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_barcap.html","id":null,"dir":"Reference","previous_headings":"","what":"Guide gizmo: capped colour bar — gizmo_barcap","title":"Guide gizmo: capped colour bar — gizmo_barcap","text":"guide displays colour bar optional caps either ends bar.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_barcap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Guide gizmo: capped colour bar — gizmo_barcap","text":"","code":"gizmo_barcap( key = \"sequence\", shape = \"triangle\", size = NULL, show = NA, alpha = NA, oob = \"keep\", theme = NULL, position = waiver(), direction = NULL )"},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_barcap.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Guide gizmo: capped colour bar — gizmo_barcap","text":"key sequence key specification. Defaults key_sequence(n = 15). Changing argument key_sequence() fine, changing key type advised. shape cap specification providing one following: cap , cap_triangle(). naming cap function without 'cap_'-prefix, e.g. \"round\". two column giving coordinates cap, like created cap functions cap_arch(). size setting size cap. NULL (default), cap size proportional shape coordinates legend.key.size theme setting. show control caps displayed ends bar. TRUE, caps always displayed. FALSE, caps never displayed. NA (default), caps displayed data range exceed limits. given , show[1] controls display lower end show[2] upper end. alpha 0 1 setting colour transparency bar. Use NA preserve alpha encoded colour . oob --bounds handling function affects cap colour. Can one following: like oob_squish. naming function without 'oob'-prefix, \"keep\". theme object style guide individually differently plot's theme settings. theme argument guide overrides combined plot's theme. position giving location guide. Can one \"top\", \"bottom\", \"left\" \"right\". direction indicating direction guide. Can \"horizontal\" \"vertical\".","code":""},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_barcap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Guide gizmo: capped colour bar — gizmo_barcap","text":" object.","code":""},{"path":[]},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_barcap.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Guide gizmo: capped colour bar — gizmo_barcap","text":"","code":"# A standard plot p <- ggplot(mpg, aes(displ, hwy, colour = cty)) + geom_point() # Just a bar p + scale_colour_viridis_c(guide = gizmo_barcap()) # Caps show up when there is data outside the limits p + scale_colour_viridis_c( limits = c(10, 30), guide = gizmo_barcap() ) # The scale's out-of-bounds handler determines cap colour p + scale_colour_viridis_c( limits = c(10, 30), oob = scales::oob_squish, guide = gizmo_barcap() ) # Customising display of the guide p + scale_colour_viridis_c( oob = scales::oob_squish, guide = gizmo_barcap( shape = \"arch\", show = c(FALSE, TRUE), size = unit(2, \"cm\"), theme = theme(legend.key.height = unit(4, \"cm\")) ) ) + theme( legend.frame = element_rect(colour = \"black\"), legend.key.width = unit(0.5, \"cm\") )"},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_density.html","id":null,"dir":"Reference","previous_headings":"","what":"Guide gizmo: kernel density estimate — gizmo_density","title":"Guide gizmo: kernel density estimate — gizmo_density","text":"guide displays kernel density estimate (KDE) aesthetic. aesthetic colour fill, shape reflect .","code":""},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_density.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Guide gizmo: kernel density estimate — gizmo_density","text":"","code":"gizmo_density( key = \"sequence\", density = NULL, density.args = list(), density.fun = stats::density, just = 0.5, oob = \"keep\", alpha = NA, theme = NULL, position = waiver(), direction = NULL )"},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_density.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Guide gizmo: kernel density estimate — gizmo_density","text":"key sequence key binned key specification. density One following: NULL using kernel density estimation data values (default). vector feed density.fun function. named x y numeric elements equal length, one returned using density() function. Please note input expected scale-transformed space, original data space. density.args additional arguments density.fun argument. applies density provided . already. density.fun use kernel density estimation density argument provided list already. just 0 1. Use 0 bottom- left-aligned densities, use 1 top- right-aligned densities 0.5 violin shapes. oob --bounds handling function affects cap colour. Can one following: like oob_squish. naming function without 'oob'-prefix, \"keep\". alpha 0 1 setting colour transparency bar. Use NA preserve alpha encoded colour . theme object style guide individually differently plot's theme settings. theme argument guide overrides combined plot's theme. position giving location guide. Can one \"top\", \"bottom\", \"left\" \"right\". direction indicating direction guide. Can \"horizontal\" \"vertical\".","code":""},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_density.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Guide gizmo: kernel density estimate — gizmo_density","text":" object.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_density.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Guide gizmo: kernel density estimate — gizmo_density","text":"Non-finite values NA NaN ignored infinite values -Inf Inf squished limits.","code":""},{"path":[]},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_density.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Guide gizmo: kernel density estimate — gizmo_density","text":"","code":"# A standard plot p <- ggplot(mpg, aes(displ, hwy, colour = cty)) + geom_point() + scale_colour_viridis_c() # Density from plot data p + guides(colour = gizmo_density()) # Using bins instead of gradient p + guides(colour = gizmo_density(\"bins\")) # Providing custom values to compute density of p + guides(colour = gizmo_density(density = runif(1000, min = 5, max = 35))) # Providing a precomputed density p + guides(colour = gizmo_density(density = density(mpg$cty, adjust = 0.5))) # Alternatively, parameters may be passed through density.args p + guides(colour = gizmo_density(density.args = list(adjust = 0.5)))"},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_grob.html","id":null,"dir":"Reference","previous_headings":"","what":"Guide gizmo: custom grob — gizmo_grob","title":"Guide gizmo: custom grob — gizmo_grob","text":"guide displays user-provided grob.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_grob.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Guide gizmo: custom grob — gizmo_grob","text":"","code":"gizmo_grob( grob, width = grobWidth(grob), height = grobHeight(grob), hjust = 0.5, vjust = 0.5, position = waiver() )"},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_grob.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Guide gizmo: custom grob — gizmo_grob","text":"grob display. width, height [][grid::unit] setting allocated width height grob respectively. hjust, vjust 0 1 setting horizontal vertical justification grob used guide x y aesthetics. position guide drawn: one \"top\", \"bottom\", \"left\", \"right\".","code":""},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_grob.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Guide gizmo: custom grob — gizmo_grob","text":" object.","code":""},{"path":[]},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_grob.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Guide gizmo: custom grob — gizmo_grob","text":"","code":"circle <- grid::circleGrob() # A standard plot with grob gizmos ggplot(mpg, aes(displ, hwy, colour = cty)) + geom_point() + guides( x.sec = gizmo_grob( circle, hjust = 0.75, width = unit(2, \"cm\"), height = unit(2, \"cm\") ), colour = gizmo_grob( circle, width = unit(1, \"cm\"), height = unit(1, \"cm\") ) )"},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_histogram.html","id":null,"dir":"Reference","previous_headings":"","what":"Guide gizmo: histogram — gizmo_histogram","title":"Guide gizmo: histogram — gizmo_histogram","text":"guide displays histogram aesthetic. aesthetic colour fill, shape reflect .","code":""},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_histogram.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Guide gizmo: histogram — gizmo_histogram","text":"","code":"gizmo_histogram( key = \"sequence\", hist = NULL, hist.args = list(), hist.fun = graphics::hist, just = 1, oob = oob_keep, alpha = NA, theme = NULL, position = waiver(), direction = NULL )"},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_histogram.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Guide gizmo: histogram — gizmo_histogram","text":"key sequence key binned key specification. hist One following: NULL computing histograms data values (default). atomic feed hist.fun function. named breaks counts numeric items, breaks item exactly one element longer counts item. typical way construct list using hist() function. Please note input expected scale-transformed space, original data space. hist.args additional arguments hist.fun argument. applies hist provided already. hist.fun use computing histograms hist argument provided list already. just 0 1. Use 0 bottom- left-aligned histograms, use 1 top- right-aligned histograms 0.5 centred histograms. oob --bounds handling function affects cap colour. Can one following: like oob_squish. naming function without 'oob'-prefix, \"keep\". alpha 0 1 setting colour transparency bar. Use NA preserve alpha encoded colour . theme object style guide individually differently plot's theme settings. theme argument guide overrides combined plot's theme. position giving location guide. Can one \"top\", \"bottom\", \"left\" \"right\". direction indicating direction guide. Can \"horizontal\" \"vertical\".","code":""},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_histogram.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Guide gizmo: histogram — gizmo_histogram","text":" object.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_histogram.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Guide gizmo: histogram — gizmo_histogram","text":"Non-finite values NA NaN ignored infinite values -Inf Inf squished limits.","code":""},{"path":[]},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_histogram.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Guide gizmo: histogram — gizmo_histogram","text":"","code":"# A standard plot p <- ggplot(mpg, aes(displ, hwy, colour = cty)) + geom_point() + scale_colour_viridis_c() # Histogram from plot data p + guides(colour = gizmo_histogram()) # Using bins instead of gradient p + guides(colour = gizmo_histogram(\"bins\")) # Providing custom values to compute histogram p + guides(colour = gizmo_histogram(hist = runif(1000, min = 5, max = 35))) # Providing precomputed histogram p + guides(colour = gizmo_histogram(hist = hist(mpg$cty, breaks = 10))) # Alternatively, parameters may be passed through hist.args p + guides(colour = gizmo_histogram(hist.arg = list(breaks = 10)))"},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_stepcap.html","id":null,"dir":"Reference","previous_headings":"","what":"Guide gizmo: capped colour steps — gizmo_stepcap","title":"Guide gizmo: capped colour steps — gizmo_stepcap","text":"guide displays binned variant colour bar optional caps either ends bar.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_stepcap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Guide gizmo: capped colour steps — gizmo_stepcap","text":"","code":"gizmo_stepcap( key = \"bins\", shape = \"triangle\", size = NULL, show = NA, alpha = NA, oob = \"keep\", theme = NULL, position = waiver(), direction = NULL )"},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_stepcap.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Guide gizmo: capped colour steps — gizmo_stepcap","text":"key bins key specificiation. Defaults key_bins(even.steps = FALSE, show.limits = NULL). Changing arguments key_bins() fine, changing key type advised. shape cap specification providing one following: cap , cap_triangle(). naming cap function without 'cap_'-prefix, e.g. \"round\". two column giving coordinates cap, like created cap functions cap_arch(). size setting size cap. NULL (default), cap size proportional shape coordinates legend.key.size theme setting. show control caps displayed ends bar. TRUE, caps always displayed. FALSE, caps never displayed. NA (default), caps displayed data range exceed limits. given , show[1] controls display lower end show[2] upper end. alpha 0 1 setting colour transparency bar. Use NA preserve alpha encoded colour . oob --bounds handling function affects cap colour. Can one following: like oob_squish. naming function without 'oob'-prefix, \"keep\". theme object style guide individually differently plot's theme settings. theme argument guide overrides combined plot's theme. position giving location guide. Can one \"top\", \"bottom\", \"left\" \"right\". direction indicating direction guide. Can \"horizontal\" \"vertical\".","code":""},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_stepcap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Guide gizmo: capped colour steps — gizmo_stepcap","text":"GizmoStepcap object.","code":""},{"path":[]},{"path":"https://teunbrand.github.io/legendry/reference/gizmo_stepcap.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Guide gizmo: capped colour steps — gizmo_stepcap","text":"","code":"# A standard plot p <- ggplot(mpg, aes(displ, hwy, colour = cty)) + geom_point() # Just some recangles p + scale_colour_viridis_c(guide = gizmo_stepcap()) # Caps show up when there is data outside the limits p + scale_colour_viridis_c( limits = c(10, 30), guide = gizmo_stepcap() ) # The scale's out-of-bounds handler determines cap colour p + scale_colour_viridis_c( limits = c(10, 30), oob = scales::oob_squish, guide = gizmo_stepcap() ) # Customising the display of the guide p + scale_colour_viridis_c( oob = scales::oob_squish, guide = gizmo_stepcap( shape = \"round\", show = c(FALSE, TRUE), size = unit(1, \"cm\"), theme = theme(legend.key.height = unit(4, \"cm\")) ) ) + theme( legend.frame = element_rect(colour = \"black\"), legend.key.width = unit(0.5, \"cm\") )"},{"path":"https://teunbrand.github.io/legendry/reference/guide-composition.html","id":null,"dir":"Reference","previous_headings":"","what":"Guide composition — guide-composition","title":"Guide composition — guide-composition","text":"Guide composition meta-guide orchestrating ensemble guides. , 'composing' guide useful visual reflection scale.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide-composition.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Guide composition — guide-composition","text":"","code":"new_compose( guides, args = list(), ..., available_aes = c(\"any\", \"x\", \"y\", \"r\", \"theta\"), call = caller_env(), super = Compose )"},{"path":"https://teunbrand.github.io/legendry/reference/guide-composition.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Guide composition — guide-composition","text":"guides guides wherein element one following: class object. returns class object. naming function, without guide_ primitive_ prefix. args arguments pass guides given either function string. ... Additional parameters pass new_guide(). available_aes giving aesthetics must match guides. call call display messages. super class object giving meta-guide composition.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide-composition.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Guide composition — guide-composition","text":" (sub-)class guide composes guides.","code":""},{"path":[]},{"path":"https://teunbrand.github.io/legendry/reference/guide-composition.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Guide composition — guide-composition","text":"","code":"# new_compose() is not intended to be used directly"},{"path":"https://teunbrand.github.io/legendry/reference/guide-gizmos.html","id":null,"dir":"Reference","previous_headings":"","what":"Guide gizmos — guide-gizmos","title":"Guide gizmos — guide-gizmos","text":"Guide gizmos speciality guide components specific one aesthetics display. Typically can composed guides guide primitives form complete guide.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide-primitives.html","id":null,"dir":"Reference","previous_headings":"","what":"Guide primitives — guide-primitives","title":"Guide primitives — guide-primitives","text":"Guide primitives building blocks complex guides. , useful visual reflection scale. purpose combined one another form complex, complete guides reflect scale way.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide-primitives.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Guide primitives — guide-primitives","text":"guide primitives simple, flexible tailored one particular aesthetic. way can reused combined .","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide_axis_base.html","id":null,"dir":"Reference","previous_headings":"","what":"Custom axis guide — guide_axis_base","title":"Custom axis guide — guide_axis_base","text":"axis guide visual representation position scales can represent x, y, theta r aesthetics. differs guide_axis() can accept custom keys can act axis coord_radial() like guide_axis_theta().","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide_axis_base.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Custom axis guide — guide_axis_base","text":"","code":"guide_axis_base( key = NULL, title = waiver(), theme = NULL, n.dodge = 1, check.overlap = FALSE, angle = waiver(), cap = \"none\", bidi = FALSE, order = 0, position = waiver() )"},{"path":"https://teunbrand.github.io/legendry/reference/guide_axis_base.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Custom axis guide — guide_axis_base","text":"key standard key specification. Defaults key_auto(). See information linked topic 'Details' section. title indicating title guide. NULL, title shown. default, waiver(), takes name scale object name specified labs() title. theme object style guide individually differently plot's theme settings. theme argument guide overrides combined plot's theme. n.dodge positive setting number layers text labels can occupy avoid overlapping labels. check.overlap indicating whether check omit overlapping text. TRUE, first, last middle labels recursively prioritised order. FALSE, labels drawn. angle specification text angle. Compared setting angle argument element_text(), argument uses heuristics automatically pick hjust vjust probably want. Can one following: NULL take angles justification settings directly theme. waiver() allow reasonable defaults special cases. -360 360 text angle degrees. cap method cap axes. One following: one following: \"none\" perform capping. \"\" cap line ends extreme breaks. \"upper\" cap line upper extreme break. \"lower\" cap line lower extreme break. [1], TRUE equivalent \"\" FALSE equivalent \"none\" options . sorted [2n] even number members. lines drawn every odd-even pair. takes scale's breaks first argument, scale's limits second argument returns [2n] described . bidi : whether ticks drawn bidirectionally (TRUE) single direction (FALSE, default). order positive specifies order guide among multiple guides. controls order guides merged multiple guides position. 0 (default), order determined hashing indicative settings guide. position giving location guide. Can one \"top\", \"bottom\", \"left\" \"right\".","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide_axis_base.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Custom axis guide — guide_axis_base","text":" object.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide_axis_base.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Custom axis guide — guide_axis_base","text":"hood, guide stack composition line, ticks labels primitives. set minor ticks, use key = \"minor\", use type argument key_manual() key_map(). use logarithmic axis, set key = \"log\".","code":""},{"path":[]},{"path":"https://teunbrand.github.io/legendry/reference/guide_axis_base.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Custom axis guide — guide_axis_base","text":"","code":"# A standard plot with custom keys p <- ggplot(mpg, aes(displ, hwy)) + geom_point() + scale_x_continuous( guide = guide_axis_base(key = key_minor()) ) + scale_y_continuous( guide = guide_axis_base(key = key_manual(c(20, 25, 30, 40))) ) p # Is translated to theta axis without fuss p + coord_radial() # To use as logarithmic axis: ggplot(msleep, aes(bodywt, brainwt)) + geom_point(na.rm = TRUE) + scale_x_continuous( transform = \"log10\", guide = guide_axis_base(\"log\") )"},{"path":"https://teunbrand.github.io/legendry/reference/guide_axis_nested.html","id":null,"dir":"Reference","previous_headings":"","what":"Nested axis guide — guide_axis_nested","title":"Nested axis guide — guide_axis_nested","text":"axis guide gives extra range annotations position scales. can used infer nesting structure labels annotate ranges.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide_axis_nested.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Nested axis guide — guide_axis_nested","text":"","code":"guide_axis_nested( key = \"range_auto\", regular_key = \"auto\", type = \"bracket\", title = waiver(), theme = NULL, angle = waiver(), cap = \"none\", bidi = FALSE, oob = \"squish\", drop_zero = TRUE, pad_discrete = NULL, levels_text = NULL, ..., order = 0, position = waiver() )"},{"path":"https://teunbrand.github.io/legendry/reference/guide_axis_nested.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Nested axis guide — guide_axis_nested","text":"key range key specification. key = \"range_auto\", additional labels inserted represent point values. regular_key standard key specification appearance regular tick marks. type Appearance ranges, either \"box\" put text boxes \"bracket\" (default) text brackets. title indicating title guide. NULL, title shown. default, waiver(), takes name scale object name specified labs() title. theme object style guide individually differently plot's theme settings. theme argument guide overrides combined plot's theme. angle specification text angle. Compared setting angle argument element_text(), argument uses heuristics automatically pick hjust vjust probably want. Can one following: NULL take angles justification settings directly theme. waiver() allow reasonable defaults special cases. -360 360 text angle degrees. cap method cap axes. One following: one following: \"none\" perform capping. \"\" cap line ends extreme breaks. \"upper\" cap line upper extreme break. \"lower\" cap line lower extreme break. [1], TRUE equivalent \"\" FALSE equivalent \"none\" options . sorted [2n] even number members. lines drawn every odd-even pair. takes scale's breaks first argument, scale's limits second argument returns [2n] described . bidi : whether ticks drawn bidirectionally (TRUE) single direction (FALSE, default). oob method dealing --bounds (oob) ranges. Can one \"squish\", \"censor\" \"none\". drop_zero whether drop near-zero width ranges (TRUE, default) preserve (FALSE). pad_discrete giving amount ranges extended given discrete variable. applied drop_zero setting. levels_text list objects customise text appears every level. ... Arguments passed primitive_bracket(), primitive_box() primitive_fence(). order positive specifies order guide among multiple guides. controls order guides merged multiple guides position. 0 (default), order determined hashing indicative settings guide. position giving location guide. Can one \"top\", \"bottom\", \"left\" \"right\".","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide_axis_nested.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Nested axis guide — guide_axis_nested","text":" object.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide_axis_nested.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Nested axis guide — guide_axis_nested","text":"hood, guide stack composition line, ticks, optionally labels either bracket, box fence primitives. default, key = \"range_auto\" incorporate 0th level labels inferred scale's labels. labels look like regular labels. offer keys opportunity display ranges alongside regular-looking labels, regular_key argument can used setup separate key display ticks ranges.","code":""},{"path":[]},{"path":"https://teunbrand.github.io/legendry/reference/guide_axis_nested.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Nested axis guide — guide_axis_nested","text":"","code":"# A plot with nested categories on the x-axis p <- ggplot(mpg, aes(interaction(drv, cyl), hwy)) + geom_boxplot() p + guides(x = \"axis_nested\") # Apply styling to brackets p + guides(x = \"axis_nested\") + theme_guide(bracket = element_line(\"red\", linewidth = 1)) # Don't drop nesting indicators that have 0-width p + guides(x = guide_axis_nested(drop_zero = FALSE)) # Change additional padding for discrete categories p + guides(x = guide_axis_nested(pad_discrete = 0)) # Change bracket type p + guides(x = guide_axis_nested(bracket = \"curvy\")) # Use boxes instead of brackets + styling of boxes p + guides(x = guide_axis_nested(type = \"box\")) + theme_guide(box = element_rect(\"limegreen\", \"forestgreen\")) # Using fences instead of brackets + styling of fences p + guides(x = guide_axis_nested(type = \"fence\", rail = \"inner\")) + theme_guide( fence.post = element_line(\"tomato\"), fence.rail = element_line(\"dodgerblue\") ) # Use as annotation of a typical axis # `regular_key` controls display of typical axis ggplot(mpg, aes(displ, hwy)) + geom_point() + guides(x = guide_axis_nested( key = key_range_manual(start = 2:3, end = 5:6, name = c(\"First\", \"Second\")), regular_key = key_manual(c(2, 2.5, 3, 5, 7)) ))"},{"path":"https://teunbrand.github.io/legendry/reference/guide_colbar.html","id":null,"dir":"Reference","previous_headings":"","what":"Custom colour bar guide — guide_colbar","title":"Custom colour bar guide — guide_colbar","text":"Similar guide_colourbar(), guide displays continuous colour fill aesthetics. additional options display caps end bar, depending --bounds values.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide_colbar.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Custom colour bar guide — guide_colbar","text":"","code":"guide_colbar( title = waiver(), key = \"auto\", first_guide = \"axis_base\", second_guide = first_guide, shape = \"triangle\", size = NULL, show = NA, nbin = 15, alpha = NA, reverse = FALSE, oob = scales::oob_keep, theme = NULL, vanilla = TRUE, position = waiver(), available_aes = c(\"colour\", \"fill\") )"},{"path":"https://teunbrand.github.io/legendry/reference/guide_colbar.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Custom colour bar guide — guide_colbar","text":"title indicating title guide. NULL, title shown. default, waiver(), takes name scale object name specified labs() title. key sequence key specification. Defaults key_sequence(n = 15). Changing argument key_sequence() fine, changing key type advised. first_guide, second_guide Guides flank colour bar. guide can specified using one following: class object. returns class object. naming function, without guide_ primitive_ prefix. first_guide placed location specified legend.text.position theme setting. second_guide placed opposite position. second_guide label suppression mechanism, labels drawn guide. shape cap specification providing one following: cap , cap_triangle(). naming cap function without 'cap_'-prefix, e.g. \"round\". two column giving coordinates cap, like created cap functions cap_arch(). size setting size cap. NULL (default), cap size proportional shape coordinates legend.key.size theme setting. show control caps displayed ends bar. TRUE, caps always displayed. FALSE, caps never displayed. NA (default), caps displayed data range exceed limits. given , show[1] controls display lower end show[2] upper end. nbin positive determining many colours use colour gradient. alpha 0 1 setting colour transparency bar. Use NA preserve alpha encoded colour . reverse whether reverse continuous guides. TRUE, guides like colour bars flipped. FALSE (default), original order maintained. oob --bounds handling function affects cap colour. Can one following: like oob_squish. naming function without 'oob'-prefix, \"keep\". theme object style guide individually differently plot's theme settings. theme argument guide overrides combined plot's theme. vanilla whether default style match vanilla guide_colourbar() (TRUE) take theme verbatim (FALSE). position giving location guide. Can one \"top\", \"bottom\", \"left\" \"right\". available_aes vector listing aesthetics guide can build.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide_colbar.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Custom colour bar guide — guide_colbar","text":" object","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide_colbar.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Custom colour bar guide — guide_colbar","text":"colours always rendered gradients, important use graphics device can render . can checked using check_device(\"gradients\").","code":""},{"path":[]},{"path":"https://teunbrand.github.io/legendry/reference/guide_colbar.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Custom colour bar guide — guide_colbar","text":"","code":"# A standard plot p <- ggplot(mpg, aes(displ, hwy)) + geom_point(aes(colour = cty)) # The colourbar shows caps when values are out-of-bounds (oob) p + scale_colour_viridis_c( limits = c(10, NA), guide = \"colbar\" ) # It also shows how oob values are handled p + scale_colour_viridis_c( limits = c(10, NA), oob = scales::oob_squish, guide = \"colbar\" ) # Adjusting the type of cap p + scale_colour_viridis_c( limits = c(10, 30), oob = scales::oob_squish, guide = guide_colbar(shape = \"round\") ) # One-sided ticks p + scale_colour_viridis_c( guide = guide_colbar(second_guide = \"none\") ) # Colour bar with minor breaks p + scale_colour_viridis_c( minor_breaks = scales::breaks_width(1), guide = guide_colbar(key = \"minor\") ) # Using log ticks on a colourbar ggplot(msleep, aes(sleep_total, sleep_rem)) + geom_point(aes(colour = bodywt), na.rm = TRUE) + scale_colour_viridis_c( transform = \"log10\", guide = guide_colbar(key = \"log\") )"},{"path":"https://teunbrand.github.io/legendry/reference/guide_colring.html","id":null,"dir":"Reference","previous_headings":"","what":"Colour rings and arcs — guide_colring","title":"Colour rings and arcs — guide_colring","text":"Similar guide_colourbar(), guide displays continuous colour fill aesthetics. Instead bar, gradient shown ring arc, can convenient cyclical palettes provided scico package.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide_colring.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Colour rings and arcs — guide_colring","text":"","code":"guide_colring( title = waiver(), key = \"auto\", start = 0, end = NULL, outer_guide = \"axis_base\", inner_guide = \"axis_base\", nbin = 300, reverse = FALSE, show_labels = \"outer\", theme = NULL, vanilla = TRUE, position = waiver(), available_aes = c(\"colour\", \"fill\"), ... )"},{"path":"https://teunbrand.github.io/legendry/reference/guide_colring.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Colour rings and arcs — guide_colring","text":"title indicating title guide. NULL, title shown. default, waiver(), takes name scale object name specified labs() title. key standard key specification. Defaults key_auto(). start, end radians specifying offset starting end points 12 o'clock. NULL default end, internally defaults start + 2 * pi. outer_guide, inner_guide Guides display outside inside colour ring. guide can specified using one following: class object. returns class object. naming function, without guide_ primitive_ prefix. nbin positive determining many colours display. reverse whether reverse continuous guides. TRUE, guides like colour bars flipped. FALSE (default), original order maintained. show_labels indicating guide labels shown. Can one \"outer\" (default), \"inner\", \"\" \"none\". Note labels can omitted related guide label suppression mechanism. theme object style guide individually differently plot's theme settings. theme argument guide overrides combined plot's theme. vanilla whether default style match vanilla guide_colourbar() (TRUE) take theme verbatim (FALSE). position giving location guide. Can one \"top\", \"bottom\", \"left\" \"right\". available_aes vector listing aesthetics guide can build. ... Arguments forwarded outer_guide inner_guide provided functions strings.","code":""},{"path":"https://teunbrand.github.io/legendry/reference/guide_colring.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Colour rings and arcs — guide_colring","text":"