Skip to content

Commit

Permalink
updated overlayLegend stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Qile0317 committed Mar 21, 2024
1 parent 2111536 commit 5c90538
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
17 changes: 11 additions & 6 deletions R/insert_legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ removeLegend <- function(apotc_ggplot) {
remove_ggplot_layers(apotc_ggplot, get_legend_layer_indicies(apotc_ggplot))
}

# FIXME
# https://qile0317.github.io/APackOfTheClones/dev/reference/overlayLegend.html

#' @title overlay a clone size legend on an APackOfTheClones plot
#'
#' @description
Expand All @@ -54,6 +51,15 @@ removeLegend <- function(apotc_ggplot) {
#' [vizAPOTC]
#' @inheritParams APOTCPlot
#'
#' @details
#' The size legend on APackOfTheClones plots are simply a collection of
#' annotation layers of the `rect`, `text`, `circle` geoms. Therefore it
#' isn't quite a ggplot legend. In the actual ggplot object, the `$layers`
#' element should all be named with an empty character `""`, and those
#' that comprise the annotation layers of the legend should be named whatever
#' `APackOfTheClones:::.ApotcLegendLayerName` is. Note that this is simply
#' an implementation detail that the user should not interfere with.
#'
#' @inherit APOTCPlot return
#' @export
#'
Expand All @@ -66,9 +72,8 @@ removeLegend <- function(apotc_ggplot) {
#' # reposition the legend to top right
#' overlayLegend(apotc_plot, legend_position = "top right")
#'
#' # use different sizes and label
#' overlayLegend(
#' apotc_plot,
#' # use different sizes and label - may be nice to use the pipe
#' apotc_plot |> overlayLegend(
#' legend_sizes = c(1, 3, 7, 9),
#' legend_label = "odd sizes"
#' )
Expand Down
9 changes: 4 additions & 5 deletions R/typecheck.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,10 @@ create_err_msg <- function(typechecker_str_vec) {
}

get_error_strings <- function(funcstrs) {
funcstrs %>%
sapply(
function(s) prepend_indefinite_article(get_err_type_str(s))
) %>%
sort()
sapply(
funcstrs,
function(s) prepend_indefinite_article(get_err_type_str(s))
) %>% sort()
}

get_err_type_str <- function(function_name_str) {
Expand Down
14 changes: 11 additions & 3 deletions man/overlayLegend.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5c90538

Please sign in to comment.