I'm trying to recreate this base-produced plot with ggplot, but I want to use a workflow more elegant than the the one <a href="http://learnr.wordpress.com/2009/05/08/ggplot2-plot-inside-a-plot/" rel="noreferrer">demonstrated here</a>, which relies directly on
.
<img src=" " alt="enter image description here">
Using <strong>ggsubplot</strong>, I tried:
which produced the following disappointing result:
<img src=" " alt="enter image description here">
Obviously needs some work, but if axes, labels and grid are added to the subplot its not far off. Any idea how to do these? I can't find any examples of this, and ggsubplot defaults to removing these elements. Thanks in advance.
Code:
grid::viewport()
<img src=" " alt="enter image description here">
Using <strong>ggsubplot</strong>, I tried:
Code:
require(ggplot2)
require(ggsubplot)
d = data.frame(x = sort(rlnorm(300)), y = sort(rlnorm(300)), grp = 1)
ggplot(d, aes(x, y)) + geom_point() + theme_bw() +
scale_x_continuous(limits=c(0, 10)) + scale_y_continuous(limits=c(0, 10)) +
geom_subplot(data=d, aes(x=5, y=1, group = grp, subplot = geom_point(aes(x, y))), width=4, height=4)
which produced the following disappointing result:
<img src=" " alt="enter image description here">
Obviously needs some work, but if axes, labels and grid are added to the subplot its not far off. Any idea how to do these? I can't find any examples of this, and ggsubplot defaults to removing these elements. Thanks in advance.