Skip to content

Arbitrary positions for guides #5488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 40 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
2cbfd11
Add legends in all positions
teunbrand Oct 17, 2023
664913d
Assemble separate guide boxes
teunbrand Oct 17, 2023
e59df5b
Add position argument to guides
teunbrand Oct 17, 2023
30da1cd
reoxygenate
teunbrand Oct 17, 2023
df59328
adapt tests
teunbrand Oct 17, 2023
73d98c5
deal with old R units
teunbrand Oct 17, 2023
793c232
integrate with main
teunbrand Oct 31, 2023
b2f5a43
rename manual position to "inside"
teunbrand Oct 31, 2023
f7a3f30
resolve spacing once
teunbrand Oct 31, 2023
e50017b
omit 'inside' option in justification
teunbrand Oct 31, 2023
bd917cf
Move more responsibility to `Guides$draw()`
teunbrand Oct 31, 2023
f34bf21
Propagate "manual" -> "inside" rename
teunbrand Oct 31, 2023
0c4dc65
Fallback for inside position
teunbrand Oct 31, 2023
ad8e964
Rearrange methods into logical order
teunbrand Oct 31, 2023
759f2af
remove vestigial stuff
teunbrand Oct 31, 2023
a1d2471
Separate numeric inside positioning from `legend.position` argument
teunbrand Nov 1, 2023
731b774
Implement plot-wise justification (#4020)
teunbrand Nov 1, 2023
32bc3e0
Partially revert bd917cf
teunbrand Nov 2, 2023
8414dfc
Add extra justification theme settings
teunbrand Nov 7, 2023
9b1f54d
Document `legend.justification.{position}`
teunbrand Nov 7, 2023
32a6953
Apply justification
teunbrand Nov 7, 2023
bf1afbd
Prevent FP warnings by partial matching
teunbrand Nov 7, 2023
5ffcdf1
Switch to new inside position
teunbrand Nov 7, 2023
5388165
Add test for justification per position
teunbrand Nov 7, 2023
6678817
Fix subsetting bug
teunbrand Nov 7, 2023
8508ebc
always add gtable rows/cols
teunbrand Nov 21, 2023
76d09f5
adjust table dimension expectations
teunbrand Nov 21, 2023
1f08cd4
adapt test
teunbrand Nov 21, 2023
5577fd1
resolve merge conflict
teunbrand Nov 21, 2023
aba04ba
Don't calculate key sizes twice
teunbrand Nov 21, 2023
ef9ad9f
Use `calc_element()`
teunbrand Nov 21, 2023
bd56edd
Use conventional indexing
teunbrand Nov 21, 2023
8a9fef5
prevent partial matching
teunbrand Nov 21, 2023
4808c3c
Move justification responsiblity to `Guides$package_box()`
teunbrand Nov 21, 2023
3c721b1
Fix bug
teunbrand Nov 25, 2023
c667d7e
resolve merge conflict
teunbrand Nov 28, 2023
dda55ee
resolve merge conflict
teunbrand Dec 8, 2023
9feb77d
incorporate guide_custom
teunbrand Dec 8, 2023
8e52c4d
incorporate guide_custom
teunbrand Dec 8, 2023
be5dd1f
Merge branch 'guide_positioning' of https://github.com/teunbrand/ggpl…
teunbrand Dec 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add position argument to guides
  • Loading branch information
teunbrand committed Oct 17, 2023
commit e59df5b9845cf3d49f8efaec997f3b931ef9439f
5 changes: 5 additions & 0 deletions R/guide-bins.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ guide_bins <- function(
ticks.length = unit(0.2, "npc"),

# general
position = NULL,
direction = NULL,
default.unit = "line",
override.aes = list(),
Expand All @@ -121,6 +122,9 @@ guide_bins <- function(
if (!is.null(title.position)) {
title.position <- arg_match0(title.position, .trbl)
}
if (!is.null(position)) {
position <- arg_match0(position, c(.trbl, "manual"))
}
if (!is.null(direction)) {
direction <- arg_match0(direction, c("horizontal", "vertical"))
}
Expand Down Expand Up @@ -169,6 +173,7 @@ guide_bins <- function(
ticks_length = ticks.length,

# general
position = position,
direction = direction,
override.aes = rename_aes(override.aes),
reverse = reverse,
Expand Down
5 changes: 5 additions & 0 deletions R/guide-colorbar.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ guide_colourbar <- function(
draw.llim = TRUE,

# general
position = NULL,
direction = NULL,
default.unit = "line",
reverse = FALSE,
Expand All @@ -171,6 +172,9 @@ guide_colourbar <- function(
if (!is.null(title.position)) {
title.position <- arg_match0(title.position, .trbl)
}
if (!is.null(position)) {
position <- arg_match0(position, c(.trbl, "manual"))
}
if (!is.null(direction)) {
direction <- arg_match0(direction, c("horizontal", "vertical"))
}
Expand Down Expand Up @@ -240,6 +244,7 @@ guide_colourbar <- function(
draw_lim = c(isTRUE(draw.llim), isTRUE(draw.ulim)),

# general
position = position,
direction = direction,
reverse = reverse,
order = order,
Expand Down
7 changes: 7 additions & 0 deletions R/guide-legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#' @param keyheight A numeric or a [grid::unit()] object specifying
#' the height of the legend key. Default value is `legend.key.height` or
#' `legend.key.size` in [theme()].
#' @param position A character string indicating where the legend should be
#' placed relative to the plot panels.
#' @param direction A character string indicating the direction of the guide.
#' One of "horizontal" or "vertical."
#' @param default.unit A character string indicating [grid::unit()]
Expand Down Expand Up @@ -145,6 +147,7 @@ guide_legend <- function(
keyheight = NULL,

# General
position = NULL,
direction = NULL,
default.unit = "line",
override.aes = list(),
Expand All @@ -168,6 +171,9 @@ guide_legend <- function(
if (!is.null(label.position)) {
label.position <- arg_match0(label.position, .trbl)
}
if (!is.null(position)) {
position <- arg_match0(position, c(.trbl, "manual"))
}

new_guide(
# Title
Expand Down Expand Up @@ -196,6 +202,7 @@ guide_legend <- function(
byrow = byrow,
reverse = reverse,
order = order,
position = position,

# Fixed parameters
available_aes = "any",
Expand Down