No known key found for this signature in database
GPG Key ID: 1D7529BE14E2BBA9
4 changed files with
47 additions and
9 deletions
-
R/geom-econodist.R
-
inst/tinytest/test_ggeconodist.R
-
man/econodist_legend_grob.Rd
-
man/geom_econodist.Rd
|
|
@ -86,10 +86,19 @@ draw_key_econodist <- function(data, params, size) { |
|
|
|
#' @examples |
|
|
|
#' ggplot(mammogram_costs, aes(x = city)) + |
|
|
|
#' geom_econodist( |
|
|
|
#' aes(ymin = tenth, median = median, ymax = ninetieth), |
|
|
|
#' aes( |
|
|
|
#' ymin = tenth, |
|
|
|
#' median = median, |
|
|
|
#' ymax = ninetieth |
|
|
|
#' ), |
|
|
|
#' stat = "identity", |
|
|
|
#' ) + |
|
|
|
#' scale_y_comma(expand = c(0,0), position = "right", limits = range(0, 800)) + |
|
|
|
#' scale_y_continuous( |
|
|
|
#' expand = c(0,0), |
|
|
|
#' position = "right", |
|
|
|
#' limits = range(0, 800), |
|
|
|
#' label = scales::comma |
|
|
|
#' ) + |
|
|
|
#' coord_flip() + |
|
|
|
#' labs( |
|
|
|
#' x = NULL, y = NULL |
|
|
|
|
|
@ -1,4 +1,24 @@ |
|
|
|
library(ggeconodist) |
|
|
|
|
|
|
|
# Placeholder with simple test |
|
|
|
expect_equal(1 + 1, 3) |
|
|
|
ggplot(mammogram_costs, aes(x = city)) + |
|
|
|
geom_econodist( |
|
|
|
aes(ymin = tenth, median = median, ymax = ninetieth), |
|
|
|
stat = "identity", |
|
|
|
) -> gg |
|
|
|
|
|
|
|
gb <- ggplotGrob(gg) |
|
|
|
|
|
|
|
expect_true(inherits(gb, "gtable")) |
|
|
|
expect_true(identical(dim(gb$layout), c(18L, 7L))) |
|
|
|
|
|
|
|
add_econodist_legend( |
|
|
|
gg, |
|
|
|
econodist_legend_grob( |
|
|
|
tenth_col = "#b07aa1", |
|
|
|
ninetieth_col = "#591a4f", |
|
|
|
), |
|
|
|
below = "subtitle", |
|
|
|
just = "right" |
|
|
|
) -> gt |
|
|
|
|
|
|
|
expect_true("econodist-legend" %in% gt$layout$name) |
|
|
|
|
|
@ -15,11 +15,11 @@ econodist_legend_grob(family = "EconSansCndLig", label_size = 10, |
|
|
|
|
|
|
|
\item{label_size}{size of legend text} |
|
|
|
|
|
|
|
\item{tenth_col}{color for the tenth bar} |
|
|
|
\item{tenth_lab, tenth_col}{label & color for the tenth bar} |
|
|
|
|
|
|
|
\item{med_col}{color for the median point} |
|
|
|
\item{med_lab, med_col}{label & color for the median point} |
|
|
|
|
|
|
|
\item{ninetieth_col}{color for the ninetieth bar} |
|
|
|
\item{ninetieth_lab, ninetieth_col}{lanbel & color for the ninetieth bar} |
|
|
|
|
|
|
|
\item{label_col}{color of the legend text} |
|
|
|
} |
|
|
|
|
|
@ -81,10 +81,19 @@ statistics. |
|
|
|
\examples{ |
|
|
|
ggplot(mammogram_costs, aes(x = city)) + |
|
|
|
geom_econodist( |
|
|
|
aes(ymin = tenth, median = median, ymax = ninetieth), |
|
|
|
aes( |
|
|
|
ymin = tenth, |
|
|
|
median = median, |
|
|
|
ymax = ninetieth |
|
|
|
), |
|
|
|
stat = "identity", |
|
|
|
) + |
|
|
|
scale_y_comma(expand = c(0,0), position = "right", limits = range(0, 800)) + |
|
|
|
scale_y_continuous( |
|
|
|
expand = c(0,0), |
|
|
|
position = "right", |
|
|
|
limits = range(0, 800), |
|
|
|
label = scales::comma |
|
|
|
) + |
|
|
|
coord_flip() + |
|
|
|
labs( |
|
|
|
x = NULL, y = NULL |
|
|
|