gf_jitter()

gf_jitter()

The gf_jitter() function will generate a jitter plot. A jitter plot is a point plot (similar to a scatter plot, such as gf_point()) but the points are moved slightly ("jittered") so that they do not overlap as much. This can help make it easier to see the frequency of values.

Arguments such as the size of the points (size = ) and the transparency of the points (alpha = ) can be manipulated as well to aid in interpretation of the distribution.

Jitter plots can also be chained together with other plots, such as boxplots.

Example 1:

# Jitter plot with categorical explanatory variable
gf_jitter( Thumb ~ Sex , data = Fingers , color = "orange" , size = 5 , alpha = .5 )

Example of output from running the code above:

Example 2:

# Jitter plot with quantitative explanatory variable
gf_jitter( Thumb Height , data = Fingers , color = "purple" , size = , alpha = .3 )

Example of output from running the code above:

Jitter plot of Thumb by Height in Fingers

Example 3:

# Boxplots with jitter plot chained on 
gf_boxplot(Thumb ~ Sex , data = Fingers, color = "black", fill = "lightgrey" ) %>%
      gf_jitter(color = "orange" , size = 3 , alpha = .5)

Example of output from running the code above:
Boxplots of Thumb by Sex in Fingers with jitter plot attached


    • Related Articles

    • gf_boxplot()

      The gf_boxplot() function will generate a boxplot (also known as a box and whiskers plot). A boxplot splits the data into quartiles, where each whisker and each half of the box contains 25% of all the observations. They are helpful for visualizing ...
    • gf_facet_grid()

      The gf_facet_grid() function will create separate plots for each group of a categorical variable. It can be chained onto plots such as gf_histogram(), gf_jitter(), and gf_bar(). Example 1: # Density histogram of Thumb faceted by Sex gf_dhistogram( ~ ...
    • gf_lm()

      The gf_lm() function overlays the best-fitting regression line on a scatter plot when chained onto gf_point(). Example: # adds a regression line gf_point(Thumb ~ Height, data = Fingers) %>%       gf_lm( color = "orange", size = 2 )
    • gf_bar()

      The gf_bar() function creates a bar graph. It can be used to visualize the distribution of a categorical variable by counting the number of observations for each group of the category. Bar graphs can also be used with the gf_facet_grid() function. ...
    • gf_density()

      The gf_density() function will overlay a density plot onto a density histogram (i.e., gf_dhistogram(), not gf_histogram()). The density plot is a smoothed out version of the distribution. They can be helpful when you want to get a better idea of the ...