mjskay / ggdist
Showing 2 of 10 files from the diff.
Newly tracked file
R/stat_slabinterval.R changed.
Newly tracked file
R/geom_slabinterval.R changed.
Other files ignored by Codecov

@@ -713,6 +713,18 @@
Loading
713 713
)
714 714
StatSlab$default_aes$size = NULL
715 715
#' @eval rd_slabinterval_shortcut_stat("slab", "slab (ridge)", geom_name = "slab")
716 +
#' @examples
717 +
#'
718 +
#' # RIDGE PLOTS
719 +
#' # "ridge" plots can be created by expanding the slabs to the limits of the plot
720 +
#' # (expand = TRUE), allowing the density estimator to be nonzero outside the
721 +
#' # limits of the data (trim = FALSE), and increasing the height of the slabs.
722 +
#' data.frame(
723 +
#'   group = letters[1:3],
724 +
#'   value = rnorm(3000, 3:1)
725 +
#' ) %>%
726 +
#'   ggplot(aes(y = group, x = value)) +
727 +
#'   stat_slab(color = "black", expand = TRUE, trim = FALSE, height = 2)
716 728
#' @export
717 729
stat_slab = make_stat(StatSlab, geom = "slab")
718 730

@@ -720,60 +720,3 @@
Loading
720 720
    stop("Unknown fill_type: ", deparse0(fill_type), '\nShould be "segments" or "gradient"')
721 721
  )
722 722
}
723 -
724 -
725 -
# shortcut geoms ----------------------------------------------------------
726 -
727 -
#' @rdname ggdist-ggproto
728 -
#' @format NULL
729 -
#' @usage NULL
730 -
#' @import ggplot2
731 -
#' @export
732 -
GeomSlab = ggproto("GeomSlab", GeomSlabinterval,
733 -
  default_key_aes = defaults(aes(
734 -
    size = 1,
735 -
    colour = NA
736 -
  ), GeomSlabinterval$default_key_aes),
737 -
738 -
  override_slab_aesthetics = function(self, s_data) {
739 -
    # we define these differently from geom_slabinterval to make this easier to use on its own
740 -
    s_data$colour = s_data[["slab_colour"]] %||% s_data[["colour"]]
741 -
    s_data$colour = apply_colour_ramp(s_data[["colour"]], s_data[["colour_ramp"]])
742 -
    s_data$fill = s_data[["slab_fill"]] %||% s_data[["fill"]]
743 -
    s_data$fill = apply_colour_ramp(s_data[["fill"]], s_data[["fill_ramp"]])
744 -
    s_data$alpha = s_data[["slab_alpha"]] %||% s_data[["alpha"]]
745 -
    s_data$size = s_data[["slab_size"]] %||% s_data[["size"]]
746 -
    s_data$linetype = s_data[["slab_linetype"]] %||% s_data[["linetype"]]
747 -
    s_data
748 -
  },
749 -
750 -
  default_params = defaults(list(
751 -
    show_point = FALSE,
752 -
    show_interval = FALSE
753 -
  ), GeomSlabinterval$default_params),
754 -
755 -
  hidden_params = union(c(
756 -
    "show_slab", "show_point", "show_interval",
757 -
    "interval_size_domain", "interval_size_range", "fatten_point"
758 -
  ), GeomSlabinterval$hidden_params),
759 -
760 -
  draw_key_slab = function(self, data, key_data, params, size) {
761 -
    # can drop all the complicated checks from this key since it's just one geom
762 -
    s_key_data = self$override_slab_aesthetics(key_data)
763 -
764 -
    # what point calls "stroke" is what we call "size", since "size" is determined automatically
765 -
    if (is.na(data$colour) && (!is.na(data$size) || !is.na(data$linetype))) {
766 -
      # because the default colour is NA, if we want to draw a key for size / linetype we need to
767 -
      # reset the colour to something reasonable
768 -
      s_key_data$colour = "black"
769 -
    }
770 -
    draw_key_polygon(s_key_data, params, size)
771 -
  }
772 -
)
773 -
# have to unset these here because defaults() does not treat NULLs as unsetting values
774 -
GeomSlab$default_key_aes$slab_colour = NULL
775 -
GeomSlab$default_key_aes$slab_size = NULL
776 -
777 -
#' @rdname geom_slabinterval
778 -
#' @export
779 -
geom_slab = make_geom(GeomSlab)
Files Coverage
R 81.99%
Project Totals (27 files) 81.99%
1
comment: false
2

3
coverage:
4
  status:
5
    project:
6
      default:
7
        target: auto
8
        threshold: 1%
9
    patch:
10
      default:
11
        target: auto
12
        threshold: 1%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading