Controlling Plot Aesthetics

Controlling plot aesthetics is straightforward in dabestr. A key feature of dabestr is the ability for users to freely customize various components of a dabestr estimation plot, allowing for the creation of an optimal-looking plot.

Getting started

At this point, it is assumed that you have already obtained the effectsize object named dabest_effectsize_obj. To add and customize specific plot components, include them as arguments in the dabest_plot() function.

dabest_plot(
  dabest_effectsize_obj,
  float_contrast = TRUE,
  plot_component = "adjustment_value"
)

Adjusting Text

All text elements in the estimation plot can be modified. This includes the value, the size and even the removal of the text elements completely.

Size

The following parameters are responsible for adjusting the size of the text elements.

Check how the size has been changed in this example:

dabest_plot(
  dabest_twogroup_obj.mean_diff,
  float_contrast = TRUE,
  swarm_x_text = 30,
  swarm_y_text = 1,
  contrast_x_text = 30,
  contrast_y_text = 5
)

Content

The following parameters are responsible for adjusting the content of the text elements.

dabest_plot(
  dabest_twogroup_obj.mean_diff,
  float_contrast = TRUE,
  swarm_label = "I love estimation statistics.",
  contrast_label = "I love it more than you do!"
)

Adjusting Visual Elements

Visual elements in dabestr refer to the shapes, lines, symbols or other visual representations that convey data and relationship in a plot. Many of these elements can be adjusted in dabestr.

Markers

The following parameters are responsible for adjusting the properties of various markers in the plot.

A <- dabest_plot(dabest_twogroup_obj.mean_diff,
  float_contrast = TRUE,
  swarm_label = "", contrast_label = "",
  raw_marker_size = 1, raw_marker_alpha = 1
)
B <- dabest_plot(dabest_twogroup_obj.mean_diff,
  float_contrast = TRUE,
  swarm_label = "", contrast_label = "",
  raw_marker_size = 2, raw_marker_alpha = 0.5
)

cowplot::plot_grid(
  plotlist = list(A, B),
  nrow = 1,
  ncol = 2,
  labels = "AUTO"
)

Axes

The following parameters are responsible for adjusting the y-axis limits for both the raw data and contrast axes of the plot. By modifying the range, it creates the effect of zooming in or out of the plot.

If your effect size is qualitatively inverted (i.e., a smaller value indicates a better outcome), you can invert the vector passed to contrast_ylim.

dabest_plot(dabest_multigroup_obj.mean_diff,
  float_contrast = FALSE,
  contrast_label = "More negative is better!",
  swarm_ylim = c(1, 5), contrast_ylim = c(0.7, -1.2)
)

Palettes

The following parameters are responsible for adjusting the plot palettes of the plot.

npg <- dabest_plot(dabest_unpaired_props.mean_diff,
  swarm_label = "", contrast_label = "",
  custom_palette = "npg"
)
nejm <- dabest_plot(dabest_unpaired_props.mean_diff,
  swarm_label = "", contrast_label = "",
  custom_palette = "nejm"
)
jama <- dabest_plot(dabest_unpaired_props.mean_diff,
  swarm_label = "", contrast_label = "",
  custom_palette = "jama"
)
locuszoom <- dabest_plot(dabest_unpaired_props.mean_diff,
  swarm_label = "", contrast_label = "",
  custom_palette = "locuszoom"
)

cowplot::plot_grid(
  plotlist = list(npg, nejm, jama, locuszoom),
  nrow = 2,
  ncol = 2
)

Misc

dabest_plot(dabest_paired_props.mean_diff, sankey = FALSE, raw_bar_width = 0.15)

dabest_plot(dabest_paired_props.mean_diff, flow = FALSE, raw_bar_width = 0.15)

right <- dabest_plot(dabest_twogroup_obj.mean_diff,
  float_contrast = FALSE,
  swarm_label = "", contrast_label = "",
  asymmetric_side = "right"
)
left <- dabest_plot(dabest_twogroup_obj.mean_diff,
  float_contrast = FALSE,
  swarm_label = "", contrast_label = "",
  asymmetric_side = "left"
)

cowplot::plot_grid(
  plotlist = list(right, left),
  nrow = 1,
  ncol = 2
)

dabest_plot(dabest_multigroup_obj.mean_diff,
  float_contrast = FALSE,
  show_baseline_ec = TRUE
)