library(ggside)
library(ggplot2)
# adding continuous y-scale to the x-side panel, when main panel mapped to discrete data
ggplot(mpg, aes(hwy, class, colour = class)) +
geom_boxplot() +
geom_xsidedensity(position = "stack") +
theme(ggside.panel.scale = .3) +
scale_xsidey_continuous(minor_breaks = NULL, limits = c(NA,1))
#If you need to specify the main scale, but need to prevent this from
#affecting the side scale. Simply add the appropriate `scale_*side*_*()` function.
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
geom_xsidehistogram() +
geom_ysidehistogram() +
scale_x_continuous(
breaks = seq(1, 6, 1),
#would otherwise remove the histogram
#as they have a lower value of 0.
limits = (c(1, 6))
) +
scale_ysidex_continuous() #ensures the x-axis of the y-side panel has its own scale.
Run the code above in your browser using DataLab