Displaying 1 result from an estimated 1 matches for "graphrang".
Did you mean:
graphrange
2013 Jul 25
1
GGplot 2 – cannot get histogram and box plot axis to match.
...onstrate the problems I have.
library(ggplot2)
#sample data from ggplot2
data(Cars93, package = "MASS")
dataSet <- Cars93
#variables to calculate the range to extend the axis
dataVector <- unlist(dataSet[,"MPG.city"])
dataRange <- max(dataVector) - min(dataVector)
graphRange <- c(min(dataVector) - dataRange/5,
max(dataVector) + dataRange/5)
#making the box plot
theBoxPlot <- ggplot(dataSet,aes_string(x = "MPG.city",y = "MPG.city"))
theBoxPlot = theBoxPlot + geom_boxplot() + expand_limits(y= graphRange) + coord_flip()
print(...