Skip to content
Prev 166221 / 398502 Next

R Stacked Histogram

On Wed, Jan 7, 2009 at 7:55 AM, Jason Rupert <jasonkrupert at yahoo.com> wrote:
If you're using ggsave, you don't need to use the dev functions.  The
following should be sufficient:

qplot(rnorm_test_data, geom = "histogram", binwidth = 1) +
         scale_x_continuous("Test Data") + scale_y_continuous("Frequency") +
         scale_fill_discrete("qplot histogram")
ggsave(file = "ggsave_qplot_output.pdf")

# Unfortunately due to a small bug in the current version of ggplot,
you need to use
# jpeg with an e to get jpegs
ggsave(file = "ggsave_qplot_output.jpeg")

# But I'd recommend using png instead - much better quality
ggsave(file = "ggsave_qplot_output.png")

# One final problem is that you're going to overwrite the plot
# on each run of your loop.  You probably want something like:

ggsave(file = paste("ggsave_qplot_output_", i, ".png", sep =""))

Hadley