jmgirard / circumplex

Compare 9a7d7ce ... +4 ... cd27159

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.


@@ -58,18 +58,40 @@
Loading
58 58
#' @param amax A positive real number corresponding to the radius of the circle.
59 59
#'   It is used to scale the amplitude values and will determine which amplitude
60 60
#'   labels are drawn.
61 -
#' @param fontsize A positive real number corresponding to the size (in pt) of
62 -
#'   the text labels (default = 12).
61 +
#' @param legend_font_size A positive real number corresponding to the size (in
62 +
#'   pt) of the text labels in the legend (default = 12).
63 +
#' @param scale_font_size A positive real number corresponding to the size (in
64 +
#'   pt) of the text labels for the amplitude and displacement scales (default =
65 +
#'   12).
63 66
#' @param lowfit A logical determining whether profiles with low model fit
64 67
#'   (<.70) should be plotted, with dashed borders (default = TRUE).
65 68
#' @param repel An experimental argument for plotting text labels instead of
66 69
#'   colors.
70 +
#' @param angle_labels A character vector specifying text labels to plot around
71 +
#'   the circle for each scale. Can also specify NULL to default to numerical
72 +
#'   angle labels or a vector of empty strings ("") to hide the labels. If not
73 +
#'   NULL, must have the same length and ordering as the \code{angles} argument
74 +
#'   to \code{ssm_analyze()}. (default = NULL)
75 +
#' @param legend.box.spacing A double corresponding to the distance (in inches)
76 +
#'   to add between the data plot and the legend (default = 0).
67 77
#' @return A ggplot variable containing a completed circular plot.
68 78
69 -
ssm_plot_circle <- function(.ssm_object, amax = NULL, fontsize = 12,
70 -
                            lowfit = TRUE, repel = FALSE) {
79 +
ssm_plot_circle <- function(.ssm_object, amax = NULL, 
80 +
                            legend_font_size = 12,
81 +
                            scale_font_size = 12,
82 +
                            lowfit = TRUE, repel = FALSE,
83 +
                            angle_labels = NULL,
84 +
                            legend.box.spacing = 0,
85 +
                            ...) {
71 86
  df <- .ssm_object$results
87 +
  
88 +
  assert_that(
89 +
    is.null(angle_labels) || 
90 +
      rlang::is_character(angle_labels, n = length(.ssm_object$details$angles))
91 +
  )
92 +
  
72 93
  angles <- as.integer(round(.ssm_object$details$angles))
94 +
  
73 95
74 96
  assert_that(is.null(amax) || is.number(amax))
75 97
@@ -104,7 +126,13 @@
Loading
104 126
  df_plot <- df_plot %>%
105 127
    dplyr::mutate(lnty = dplyr::if_else(fit_est >= .70, "solid", "dashed"))
106 128
107 -
  p <- circle_base(angles = angles, amax = amax, fontsize = fontsize) +
129 +
  p <- 
130 +
    circle_base(
131 +
      angles = angles, 
132 +
      amax = amax, 
133 +
      fontsize = scale_font_size, 
134 +
      labels = angle_labels
135 +
    ) +
108 136
    ggplot2::scale_color_hue() +
109 137
    ggplot2::scale_fill_hue()
110 138
@@ -129,7 +157,8 @@
Loading
129 157
      fill = ggplot2::guide_legend(.ssm_object$details$results_type)
130 158
    ) +
131 159
    ggplot2::theme(
132 -
      legend.text = ggplot2::element_text(size = fontsize)
160 +
      legend.text = ggplot2::element_text(size = legend_font_size),
161 +
      legend.box.spacing = ggplot2::unit(legend.box.spacing, "in")
133 162
    ) +
134 163
    ggplot2::scale_linetype_identity()
135 164
@@ -140,8 +169,10 @@
Loading
140 169
        ggplot2::aes(x = x_est, y = y_est, label = label),
141 170
        nudge_x = -25 - df_plot$x_est,
142 171
        direction = "y",
143 -
        hjust = 1
144 -
      ) + ggplot2::theme(legend.position = "none")
172 +
        hjust = 1,
173 +
        size = legend_font_size / 2.8346438836889
174 +
      ) + 
175 +
      ggplot2::theme(legend.position = "none")
145 176
  }
146 177
  
147 178
  p
@@ -234,11 +265,14 @@
Loading
234 265
}
235 266
236 267
# Create an Empty Circular Plot
237 -
circle_base <- function(angles, labels = sprintf("%d\u00B0", angles),
268 +
circle_base <- function(angles, labels = NULL,
238 269
                        amax = 0.5, fontsize = 12) {
270 +
  
271 +
  if (is.null(labels)) labels <- sprintf("%d\u00B0", angles)
272 +
  
239 273
  ggplot2::ggplot() +
240 274
    # Require plot to be square and remove default styling
241 -
    ggplot2::coord_fixed() +
275 +
    ggplot2::coord_fixed(clip = "off") +
242 276
    ggplot2::theme_void(base_size = fontsize) +
243 277
    # Expand the axes multiplicatively to fit labels
244 278
    ggplot2::scale_x_continuous(expand = c(0.25, 0)) +

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
R 0.03% 88.54%
src 100.00%
Project Totals (11 files) 90.21%
Loading