Sweet!  The missing "e".  That was it!  Yeah!  Thanks again.   I guess I will 
get some sleep tonight.  
 
Well, one last questions about stack plot (please forgive the lame example 
below).  I thought the below allow me to resize the the "title" of the stacked 
histogram, but no luck.  Any suggestions as to the modificaiton necessary to 
get it to work?  Right now the title is obscured by the plot and my boss will 
be none too happy.  Thanks again.  
 
I think this is my last stumper question for the day:).
 
 
library(ggplot2)
 
rnorm_test_data_1<-rnorm(100,3,1)
rnorm_test_data_2<-rnorm(100,3,1)
nor_1<-cbind(Test="norm1", Data=rnorm_test_data_1)
nor_2<-cbind(Test="norm2", Data=rnorm_test_data_1)
nor_data<-rbind(nor_1, nor_2)
nor_data_frame<-data.frame(Test=nor_data[,1],Data=nor_data[,2])
qplot(nor_data_frame$Data, data = nor_data_frame, binwidth = 3.0, 
      fill = nor_data_frame$Test,
      main = list(as.character("Test Histogram", cex=0.7, font=7)))
 
> sessionInfo()
R version 2.8.0 (2008-10-20) 
i386-pc-mingw32 
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.1252;LC_MONETARY=English_United 
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods   
base     
other attached packages:
 [1] ggplot2_0.8.1      reshape_0.8.2      RColorBrewer_1.0-2 proto_0.3-8       
 [5] plyr_0.1.4         nortest_1.0        fBasics_280.74     timeSeries_290.79 
 [9] timeDate_290.81    vcd_1.2-1          MASS_7.2-44        colorspace_1.0-0  
> 


--- On Wed, 1/7/09, hadley wickham <h.wick...@gmail.com> wrote:

From: hadley wickham <h.wick...@gmail.com>
Subject: Re: [R] R Stacked Histogram
To: jasonkrup...@yahoo.com
Cc: r-help@r-project.org
Date: Wednesday, January 7, 2009, 9:20 AM

On Wed, Jan 7, 2009 at 7:55 AM, Jason Rupert <jasonkrup...@yahoo.com>
wrote:
> That worked!  Thank you very much for the help.
>
> I think I have one last question about qplot in ggplot2, That is exporting
the plot to JPG while in a loop.   I tried what was recommended in "Re: [R]
jpeg() creating empty files with qplot() in a loop", however, I received
some errors (see below).  I also tried using a PDF, but that did not work
either, i.e. the PDF produced was blank.  Oddly enough the results produced
using "dev.print(file="qplot_output.jpg", device=jpeg, width=600)
" in a loop are blank, i.e. the JPG file is there, but it is blank. 
Unfortunately,  "ggsave(file="ggsave_qplot_output.jpg")"
does not even produce a JPG file output.  Any help at this point is greatly
appreciated.  Is the problem related to the fact that I need to use the plain
"hist" and "dev.print" prior to using ggplot's qplot?

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

-- 
http://had.co.nz/



      
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to