Introduction

pinpoint produces an interactive visualization inhabiting the space between a bar plot, a scatter plot, a box plot, and a histogram.

Hover over each point to see its distance from the specified compare mark (defaults to mean).

library(pinpoint) #remotes::install_github("daranzolin/pinpoint)
library(magrittr)
mtcars$name <- rownames(mtcars)
mtcars %>% 
  pinpoint(x = mpg, 
           fill = cyl, 
           tooltip = name,
           compare_mark = "diff_from_mean",
           title = "MPG by Cylinder") 

You can jitter the points to avoid overlap:

mtcars %>% 
  pinpoint(x = mpg, 
           fill = cyl, 
           tooltip = name,
           compare_mark = "diff_from_mean",
           title = "MPG by Cylinder") %>% 
  pp_style(jitter_width = 70)

Or adjust the fill color and size of the points:

mtcars %>% 
  pinpoint(x = mpg, 
           fill = "firebrick", 
           tooltip = name,
           compare_mark = "diff_from_mean",
           title = "MPG by Cylinder") %>% 
  pp_style(jitter_width = 70,
           point_radius = 5)

Change the line of comparison:

mtcars %>% 
  pinpoint(x = mpg, 
           fill = cyl, 
           tooltip = name,
           compare_mark = "diff_from_median", # also accepts a numeric value
           title = "MPG by Cylinder") %>% 
  pp_style(jitter_width = 70)

Control the axis:

mtcars %>% 
  pinpoint(x = mpg, 
           fill = cyl, 
           tooltip = name,
           compare_mark = 21,
           title = "MPG by Cylinder") %>% 
  pp_style(jitter_width = 70,
           axis_range = c(20, 25),
           ticks = 3)

Draw the quantiles:

mtcars %>% 
  pinpoint(x = mpg, 
           fill = cyl, 
           tooltip = name,
           compare_mark = "diff_from_mean",
           title = "MPG by Cylinder") %>% 
  pp_style(jitter_width = 70) %>% 
  draw_quantiles(color = "steelblue") # default is 25th and 75th

Or the standard deviations:

mtcars %>% 
  pinpoint(x = mpg, 
           fill = cyl, 
           tooltip = name,
           compare_mark = "diff_from_mean",
           title = "MPG by Cylinder") %>% 
  pp_style(jitter_width = 70) %>% 
  draw_deviations(1, color = "red")

Other options in pp_style: