My goal is to create essentially a thumbnail of a densityplot.
My attempt below tries to strip all the nice extras that
ggplot2 provides. I would love it if the resulting image
had no margins. That is, the bottom of the image was
identical to the 'baseline' of the density plot, and the
sides of the image were where the vertical lines on the ends
of the plot are.
However, I only see three margin options,
plot.margin
axis.ticks.margin
panel.margin
I tried setting them all to 0 length below, but I still have
what I consider a 'margin' to be present on the figure.
Is there a 'standard' way to do what I want, or should I just
use negative lengths until the result is as I want?
Thanks!
--Erik
age <- rnorm(100, 50, 10)
qplot(age, geom = "density") +
opts(axis.text.x = theme_blank(),
axis.text.y = theme_blank(),
axis.ticks = theme_blank(),
panel.grid.minor = theme_blank(),
panel.grid.major = theme_blank(),
plot.margin = unit(c(0, 0, 0, 0), "cm"),
axis.ticks.margin = unit(0, "cm"),
panel.margin = unit(c(0, 0, 0, 0), "cm")) +
labs(x = "", y = "")
I use the theme_nothing script attached. It strips away almost
everything, saving only a small margin. You should be able to take it
out by messing with the script.
Cheers
david.