[R] dev.new() within a loop {SOLVED]
David Winsemius
dwinsemius at comcast.net
Sun Nov 13 15:14:42 CET 2011
In a private communication this poster has indicated that he
eventually found the answer by Googling the question. (The solution
was as described in the FAQ.)
--
David.
On Nov 13, 2011, at 5:21 AM, Giovanni Azua wrote:
> Hello David,
>
> On Nov 13, 2011, at 5:20 AM, David Winsemius wrote:
>>> However, when executing plot_raw which invokes dev.new(..) all
>>> windows come out blank whereas if I execute each file outside of a
>>> loop then I can see the plots properly.
>>
>> Perhaps ...(you did not say what package this plot_raw function
>> comes from) ... Read the FAQ about why lattice plot don't print.
>> (It applies to all grid based plotting functions.)
>>
> plot_raw is my own function which just calls ggplot2. So basically I
> am not using Lattice.
>
> What can I do differently to avoid the new windows coming back empty?
>
> Thanks in advance,
> Best regards,
> Giovanni
>
> plot_raw <-
> function(data,connect=TRUE,y_break=500,y_top=-1,label="") {
> dev.new()
> title <- paste(label, sep="")
> if (y_top == -1) {
> y_top <- max(data$Y)
> }
>
> if (!decouple) {
> # add fake group
> data$Workload <- 'All'
> }
>
> p <-
> ggplot
> (data,aes(x=Time,y=Y,group=Workload,shape=Workload,colour=Workload)) +
> geom_point(fill="white", size=3) +
> scale_y_continuous(breaks=seq(0,max(data$Y),y_break), limits=c(0,
> y_top)) +
> scale_y_continuous(breaks=seq(0,y_limit_top(data$Y,data$se),
> y_break_step(data$Y,data$se)),
> limits=c(0, y_limit_top(data$Y,data$se))) +
> opts(title=title) + theme_bw() +
> scale_x_continuous(breaks=data$Time, labels=as.character(data
> $Time))
>
> if (connect) {
> p + geom_line()
> } else {
> p
> }
> }
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list