Learn R Programming

sjPlot (version 1.7)

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 of 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://www.r-bloggers.com/setting-axis-limits-on-ggplot-charts/{r-bloggers.com}

Examples

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

Run the code above in your browser using DataLab