gf_point()

gf_point()

The gf_point() function can be used to create a scatterplot, or to plot a specified point, such as a specific value along the x-axis.

Example 1:

gf_point( Thumb ~ Height , data = Fingers , size = 2 )


Example of output from running the code above:


Example 2:

# Save the sample b1 and set up the sampling distribution of b1s
sample_b1 <- b1(Tip ~ Condition, data = TipExperiment)
sdob1 <- do(1000)* b1(Tip ~ shuffle(Condition), data = TipExperiment)
# Plot the sample b1 value along the x-axis of the sdob1
gf_histogram(~b1, data = sdob1, fill = ~middle(b1, .95), bins=100) %>%
      gf_point(0 ~ sample_b1, color = "black")

Example of output from running the code above:


    • Related Articles

    • 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_vline()

      The gf_vline() function will add a vertical line onto a plot. You can plot the line by referencing a value in a data frame (Example 1), or by specifying the point along the axis where the line should run through (Example 2). Example 1: # Save the ...
    • 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 ...
    • 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 ...