Learn R Programming

sjPlot (version 2.0.0)

adjust_plot_range: Adjust y range of ggplot-objects

Description

This method adjusts the y-range of a ggplot-object, which is useful when value labels are outside the plot region. A modified ggplot-object will be returned with adjusted y-range so everything should be visible. Note that this function only works on scale_y_continuous.

Usage

adjust_plot_range(gp, upperMargin = 1.05)

Arguments

Value

The same ggplot-object, with adjusted y-range, so all graphics and labels should be visible.

References

http://blog.ouseful.info/2013/12/03/setting-axis-limits-on-ggplot-charts/{OUseful.Info (2013)}

Examples

Run this code
# sample data set
library(sjmisc)
data(efc)
# show frequencies of relationship-variable and
# retrieve plot object
gp <- sjp.frq(efc$e15relat, prnt.plot = FALSE)
# show current plot
plot(gp$plot)
# show adjusted plot
adjust_plot_range(gp$plot)

Run the code above in your browser using DataLab