Help! I couldn't put multiple qplot on the same page...

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Help! I couldn't put multiple qplot on the same page...

LosemindL
Hi all,

I am stuck at ploting multiple graphs on one page. I don't why it doesn't work.

All the 6 plots are either exactly the same, or they simply don't plot
at all. I made sure that in each iteration the "datasub" and
"factorsub" are different ...

Could you please help me?

Thanks a lot!

I did my homework and followed the following advice:

http://stackoverflow.com/questions/1249548/side-by-side-plots-with-ggplot2-in-r

my.multiplot <- function(..., plotlist=NULL, cols) {
    require(grid)

    # Make a list from the ... arguments and plotlist
    plots <- c(list(...), plotlist)

    numPlots = length(plots)

    # Make the panel
    plotCols = cols                          # Number of columns of plots
    plotRows = ceiling(numPlots/plotCols) # Number of rows needed,
calculated from # of cols

    # Set up the page
    grid.newpage()
    pushViewport(viewport(layout = grid.layout(plotRows, plotCols)))
    vplayout <- function(x, y)
        viewport(layout.pos.row = x, layout.pos.col = y)

    # Make each plot, in the correct location
    for (i in 1:numPlots) {
        curRow = ceiling(i/plotCols)
        curCol = (i-1) %% plotCols + 1
        print(plots[[i]], vp = vplayout(curRow, curCol ))
    }

}


My code is as below:

----------------------------


myplotlist=vector('list', 6)
nCount=0;

for (j in myyears)
{
        print(j)
        nCount=nCount+1
       
                    #...
                    # prepare datasub and factorsub for different j...
                    #...
        tmp<-data.frame(as.double(datasub),as.numeric(factorsub))
        tt=qplot(factor(as.numeric(factorsub)),as.double(datasub),data=tmp,geom
= "boxplot",ylab='Chg',xlab='Hours', main=j)
       
        myplotlist[nCount]=tt
       
}

my.multiplot(plotlist=myplotlist,cols=3)

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Help! I couldn't put multiple qplot on the same page...

LosemindL
If I put a "windows()" in front of the qplot command in the above code
and simply wanted to have each plot graphed on different pages...


Six graph windows opened but none of them had any content...  they are
all blank...

What's the problem?

Thx

On 12/7/11, Michael <[hidden email]> wrote:

> Hi all,
>
> I am stuck at ploting multiple graphs on one page. I don't why it doesn't
> work.
>
> All the 6 plots are either exactly the same, or they simply don't plot
> at all. I made sure that in each iteration the "datasub" and
> "factorsub" are different ...
>
> Could you please help me?
>
> Thanks a lot!
>
> I did my homework and followed the following advice:
>
> http://stackoverflow.com/questions/1249548/side-by-side-plots-with-ggplot2-in-r
>
> my.multiplot <- function(..., plotlist=NULL, cols) {
>     require(grid)
>
>     # Make a list from the ... arguments and plotlist
>     plots <- c(list(...), plotlist)
>
>     numPlots = length(plots)
>
>     # Make the panel
>     plotCols = cols                          # Number of columns of plots
>     plotRows = ceiling(numPlots/plotCols) # Number of rows needed,
> calculated from # of cols
>
>     # Set up the page
>     grid.newpage()
>     pushViewport(viewport(layout = grid.layout(plotRows, plotCols)))
>     vplayout <- function(x, y)
>         viewport(layout.pos.row = x, layout.pos.col = y)
>
>     # Make each plot, in the correct location
>     for (i in 1:numPlots) {
>         curRow = ceiling(i/plotCols)
>         curCol = (i-1) %% plotCols + 1
>         print(plots[[i]], vp = vplayout(curRow, curCol ))
>     }
>
> }
>
>
> My code is as below:
>
> ----------------------------
>
>
> myplotlist=vector('list', 6)
> nCount=0;
>
> for (j in myyears)
> {
> print(j)
> nCount=nCount+1
>
>                     #...
>                     # prepare datasub and factorsub for different j...
>                     #...
> tmp<-data.frame(as.double(datasub),as.numeric(factorsub))
> tt=qplot(factor(as.numeric(factorsub)),as.double(datasub),data=tmp,geom
> = "boxplot",ylab='Chg',xlab='Hours', main=j)
>
> myplotlist[nCount]=tt
>
> }
>
> my.multiplot(plotlist=myplotlist,cols=3)
>

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Help! I couldn't put multiple qplot on the same page...

LosemindL
I found that if I run each "qplot" manually it would plot out something...

but if I put it into the loop,

it just doesn't work at all - sometimes it refused to plot anything...

On 12/7/11, Michael <[hidden email]> wrote:

> If I put a "windows()" in front of the qplot command in the above code
> and simply wanted to have each plot graphed on different pages...
>
>
> Six graph windows opened but none of them had any content...  they are
> all blank...
>
> What's the problem?
>
> Thx
>
> On 12/7/11, Michael <[hidden email]> wrote:
>> Hi all,
>>
>> I am stuck at ploting multiple graphs on one page. I don't why it doesn't
>> work.
>>
>> All the 6 plots are either exactly the same, or they simply don't plot
>> at all. I made sure that in each iteration the "datasub" and
>> "factorsub" are different ...
>>
>> Could you please help me?
>>
>> Thanks a lot!
>>
>> I did my homework and followed the following advice:
>>
>> http://stackoverflow.com/questions/1249548/side-by-side-plots-with-ggplot2-in-r
>>
>> my.multiplot <- function(..., plotlist=NULL, cols) {
>>     require(grid)
>>
>>     # Make a list from the ... arguments and plotlist
>>     plots <- c(list(...), plotlist)
>>
>>     numPlots = length(plots)
>>
>>     # Make the panel
>>     plotCols = cols                          # Number of columns of plots
>>     plotRows = ceiling(numPlots/plotCols) # Number of rows needed,
>> calculated from # of cols
>>
>>     # Set up the page
>>     grid.newpage()
>>     pushViewport(viewport(layout = grid.layout(plotRows, plotCols)))
>>     vplayout <- function(x, y)
>>         viewport(layout.pos.row = x, layout.pos.col = y)
>>
>>     # Make each plot, in the correct location
>>     for (i in 1:numPlots) {
>>         curRow = ceiling(i/plotCols)
>>         curCol = (i-1) %% plotCols + 1
>>         print(plots[[i]], vp = vplayout(curRow, curCol ))
>>     }
>>
>> }
>>
>>
>> My code is as below:
>>
>> ----------------------------
>>
>>
>> myplotlist=vector('list', 6)
>> nCount=0;
>>
>> for (j in myyears)
>> {
>> print(j)
>> nCount=nCount+1
>>
>>                     #...
>>                     # prepare datasub and factorsub for different j...
>>                     #...
>> tmp<-data.frame(as.double(datasub),as.numeric(factorsub))
>> tt=qplot(factor(as.numeric(factorsub)),as.double(datasub),data=tmp,geom
>> = "boxplot",ylab='Chg',xlab='Hours', main=j)
>>
>> myplotlist[nCount]=tt
>>
>> }
>>
>> my.multiplot(plotlist=myplotlist,cols=3)
>>
>

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Help! I couldn't put multiple qplot on the same page...

Yihui Xie-2
This is probably one of the most frequently asked questions. The
answer is to print() the objects. See R FAQ 7.22.

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f

Regards,
Yihui
--
Yihui Xie <[hidden email]>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Wed, Dec 7, 2011 at 4:38 PM, Michael <[hidden email]> wrote:
> I found that if I run each "qplot" manually it would plot out something...
>
> but if I put it into the loop,
>
> it just doesn't work at all - sometimes it refused to plot anything...
>

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Help! I couldn't put multiple qplot on the same page...

LosemindL
Thanks a lot!

Now I can see the individual plot, but still not the
originally-desired multi-plot-on-one-page?

Any thoughts? Thanks again!

On 12/7/11, Yihui Xie <[hidden email]> wrote:

> This is probably one of the most frequently asked questions. The
> answer is to print() the objects. See R FAQ 7.22.
>
> http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f
>
> Regards,
> Yihui
> --
> Yihui Xie <[hidden email]>
> Phone: 515-294-2465 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 2215 Snedecor Hall, Ames, IA
>
>
>
> On Wed, Dec 7, 2011 at 4:38 PM, Michael <[hidden email]> wrote:
>> I found that if I run each "qplot" manually it would plot out something...
>>
>> but if I put it into the loop,
>>
>> it just doesn't work at all - sometimes it refused to plot anything...
>>
>

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Help! I couldn't put multiple qplot on the same page...

Yihui Xie-2
This is another frequently asked question about ggplot2, but I don't
know. What I can tell you is, if you use Sweave, you probably can
consider the knitr package, which enables you to put any plots on one
"page" (yes, I'm cheating via LaTeX); see Figure 1 in the manual:
https://github.com/downloads/yihui/knitr/knitr-manual.pdf

Regards,
Yihui
--
Yihui Xie <[hidden email]>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Wed, Dec 7, 2011 at 5:08 PM, Michael <[hidden email]> wrote:

> Thanks a lot!
>
> Now I can see the individual plot, but still not the
> originally-desired multi-plot-on-one-page?
>
> Any thoughts? Thanks again!
>
> On 12/7/11, Yihui Xie <[hidden email]> wrote:
>> This is probably one of the most frequently asked questions. The
>> answer is to print() the objects. See R FAQ 7.22.
>>
>> http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f
>>
>> Regards,
>> Yihui
>> --
>> Yihui Xie <[hidden email]>
>> Phone: 515-294-2465 Web: http://yihui.name
>> Department of Statistics, Iowa State University
>> 2215 Snedecor Hall, Ames, IA
>>
>>
>>
>> On Wed, Dec 7, 2011 at 4:38 PM, Michael <[hidden email]> wrote:
>>> I found that if I run each "qplot" manually it would plot out something...
>>>
>>> but if I put it into the loop,
>>>
>>> it just doesn't work at all - sometimes it refused to plot anything...
>>>
>>

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Help! I couldn't put multiple qplot on the same page...

LosemindL
In reply to this post by LosemindL
I also did (inside the for loop):

        if (nCount==1) p1=tt
        if (nCount==2) p2=tt
        if (nCount==3) p3=tt
        if (nCount==4) p4=tt
        if (nCount==5) p5=tt
        if (nCount==6) p6=tt

...

and then after the loop:

windows()
my.multiplot(p1, p2, p3, p4, p5, p6, cols=3)


All the sub-plots in that multi-plot page are all identical!

I cannot imagine how many hours I have been spending on fighting this issue!

On 12/7/11, Michael <[hidden email]> wrote:

> Thanks a lot!
>
> Now I can see the individual plot, but still not the
> originally-desired multi-plot-on-one-page?
>
> Any thoughts? Thanks again!
>
> On 12/7/11, Yihui Xie <[hidden email]> wrote:
>> This is probably one of the most frequently asked questions. The
>> answer is to print() the objects. See R FAQ 7.22.
>>
>> http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f
>>
>> Regards,
>> Yihui
>> --
>> Yihui Xie <[hidden email]>
>> Phone: 515-294-2465 Web: http://yihui.name
>> Department of Statistics, Iowa State University
>> 2215 Snedecor Hall, Ames, IA
>>
>>
>>
>> On Wed, Dec 7, 2011 at 4:38 PM, Michael <[hidden email]> wrote:
>>> I found that if I run each "qplot" manually it would plot out
>>> something...
>>>
>>> but if I put it into the loop,
>>>
>>> it just doesn't work at all - sometimes it refused to plot anything...
>>>
>>
>

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Help! I couldn't put multiple qplot on the same page...

Tengfei Yin
In reply to this post by LosemindL
library(gridExtra)
?grid.arrange

I found this function convenient to me, it could arrange multiple ggplot
object on the same view window
p1 <- qplot(...)
p2 <- qplot(...)
....
grid.arrange(p1, p2, ..., nrow = 2)

different from your design, but for the same purpose I guess.

cheers

Tengfei

On Wed, Dec 7, 2011 at 5:08 PM, Michael <[hidden email]> wrote:

> Thanks a lot!
>
> Now I can see the individual plot, but still not the
> originally-desired multi-plot-on-one-page?
>
> Any thoughts? Thanks again!
>
> On 12/7/11, Yihui Xie <[hidden email]> wrote:
> > This is probably one of the most frequently asked questions. The
> > answer is to print() the objects. See R FAQ 7.22.
> >
> >
> http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f
> >
> > Regards,
> > Yihui
> > --
> > Yihui Xie <[hidden email]>
> > Phone: 515-294-2465 Web: http://yihui.name
> > Department of Statistics, Iowa State University
> > 2215 Snedecor Hall, Ames, IA
> >
> >
> >
> > On Wed, Dec 7, 2011 at 4:38 PM, Michael <[hidden email]> wrote:
> >> I found that if I run each "qplot" manually it would plot out
> something...
> >>
> >> but if I put it into the loop,
> >>
> >> it just doesn't work at all - sometimes it refused to plot anything...
> >>
> >
>
> ______________________________________________
> [hidden email] 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.
>



--
Tengfei Yin
MCDB PhD student
1620 Howe Hall, 2274,
Iowa State University
Ames, IA,50011-2274
Homepage: www.tengfei.name

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Help! I couldn't put multiple qplot on the same page...

LosemindL
In reply to this post by Yihui Xie-2
Very surprisingly in the generated multi-plot-on-the-same-page, the
titles of the sub-plots are different... but their contents are the
same(ie. the plotted curves are the same)...

How could this happen?

Any thoughts?

On 12/7/11, Yihui Xie <[hidden email]> wrote:

> This is another frequently asked question about ggplot2, but I don't
> know. What I can tell you is, if you use Sweave, you probably can
> consider the knitr package, which enables you to put any plots on one
> "page" (yes, I'm cheating via LaTeX); see Figure 1 in the manual:
> https://github.com/downloads/yihui/knitr/knitr-manual.pdf
>
> Regards,
> Yihui
> --
> Yihui Xie <[hidden email]>
> Phone: 515-294-2465 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 2215 Snedecor Hall, Ames, IA
>
>
>
> On Wed, Dec 7, 2011 at 5:08 PM, Michael <[hidden email]> wrote:
>> Thanks a lot!
>>
>> Now I can see the individual plot, but still not the
>> originally-desired multi-plot-on-one-page?
>>
>> Any thoughts? Thanks again!
>>
>> On 12/7/11, Yihui Xie <[hidden email]> wrote:
>>> This is probably one of the most frequently asked questions. The
>>> answer is to print() the objects. See R FAQ 7.22.
>>>
>>> http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f
>>>
>>> Regards,
>>> Yihui
>>> --
>>> Yihui Xie <[hidden email]>
>>> Phone: 515-294-2465 Web: http://yihui.name
>>> Department of Statistics, Iowa State University
>>> 2215 Snedecor Hall, Ames, IA
>>>
>>>
>>>
>>> On Wed, Dec 7, 2011 at 4:38 PM, Michael <[hidden email]> wrote:
>>>> I found that if I run each "qplot" manually it would plot out
>>>> something...
>>>>
>>>> but if I put it into the loop,
>>>>
>>>> it just doesn't work at all - sometimes it refused to plot anything...
>>>>
>>>
>

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Help! I couldn't put multiple qplot on the same page...

LosemindL
In reply to this post by Tengfei Yin
Still the same problem - in the final aggregated plots, all the titles
are diffrent(which is good), but the curve shapes are the same...

How could this happen?

Is this a bug?

On 12/7/11, Tengfei Yin <[hidden email]> wrote:

> library(gridExtra)
> ?grid.arrange
>
> I found this function convenient to me, it could arrange multiple ggplot
> object on the same view window
> p1 <- qplot(...)
> p2 <- qplot(...)
> ....
> grid.arrange(p1, p2, ..., nrow = 2)
>
> different from your design, but for the same purpose I guess.
>
> cheers
>
> Tengfei
>
> On Wed, Dec 7, 2011 at 5:08 PM, Michael <[hidden email]> wrote:
>
>> Thanks a lot!
>>
>> Now I can see the individual plot, but still not the
>> originally-desired multi-plot-on-one-page?
>>
>> Any thoughts? Thanks again!
>>
>> On 12/7/11, Yihui Xie <[hidden email]> wrote:
>> > This is probably one of the most frequently asked questions. The
>> > answer is to print() the objects. See R FAQ 7.22.
>> >
>> >
>> http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f
>> >
>> > Regards,
>> > Yihui
>> > --
>> > Yihui Xie <[hidden email]>
>> > Phone: 515-294-2465 Web: http://yihui.name
>> > Department of Statistics, Iowa State University
>> > 2215 Snedecor Hall, Ames, IA
>> >
>> >
>> >
>> > On Wed, Dec 7, 2011 at 4:38 PM, Michael <[hidden email]> wrote:
>> >> I found that if I run each "qplot" manually it would plot out
>> something...
>> >>
>> >> but if I put it into the loop,
>> >>
>> >> it just doesn't work at all - sometimes it refused to plot anything...
>> >>
>> >
>>
>> ______________________________________________
>> [hidden email] 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.
>>
>
>
>
> --
> Tengfei Yin
> MCDB PhD student
> 1620 Howe Hall, 2274,
> Iowa State University
> Ames, IA,50011-2274
> Homepage: www.tengfei.name
>

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Help! I couldn't put multiple qplot on the same page...

William Dunlap
I've lost track of the changes you've done to your
code and your original code was not runnable.  However,
I noticed it used the line
  myplotlist[nCount]=tt
where myplotlist was a list.  Try changing that to
  myplotlist[[nCount]] <- tt
(the '=' is acceptable but the the '[' is wrong).

I made that change to the code you posted at "Wed Dec 7 23:32:08 CET 2011"
(in the R-help archives), along with some extra lines to generate data,
and it seemed to work.  When using the original
myplotlist[nCount] <- tt I got one warning per plot
  Warning messages:
  1: In myplotlist[nCount] = tt :
    number of items to replace is not a multiple of replacement length
  2: In myplotlist[nCount] = tt :
    number of items to replace is not a multiple of replacement length
  3: In myplotlist[nCount] = tt :
    number of items to replace is not a multiple of replacement length
  4: In myplotlist[nCount] = tt :
    number of items to replace is not a multiple of replacement length
  5: In myplotlist[nCount] = tt :
    number of items to replace is not a multiple of replacement length
  6: In myplotlist[nCount] = tt :
    number of items to replace is not a multiple of replacement length
and no plots were displayed.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

--- start of modified R script ---
my.multiplot <- function(..., plotlist=NULL, cols) {
    require(grid)

    # Make a list from the ... arguments and plotlist
    plots <- c(list(...), plotlist)

    numPlots  <-  length(plots)

    # Make the panel
    plotCols  <-  cols                       # Number of columns of plots
    plotRows  <-  ceiling(numPlots/plotCols) # Number of rows needed

    # Set up the page
    grid.newpage()
    pushViewport(viewport(layout = grid.layout(plotRows, plotCols)))
    vplayout <- function(x, y) {
        viewport(layout.pos.row = x, layout.pos.col = y)
    }

    # Make each plot, in the correct location
    for (i in 1:numPlots) {
        curRow <- ceiling(i/plotCols)
        curCol <- (i-1) %% plotCols + 1
        print(plots[[i]], vp = vplayout(curRow, curCol ))
    }

}


myyears <- 1996:2001
myplotlist <- vector('list', length(myyears))
nCount <- 0;

for (j in myyears)
{
        print(j)
        nCount <- nCount+1

        #...
        # prepare datasub and factorsub for different j...
        datasub <- j + ((1:10)%%nCount)/12 # different shape of curve each year
        factorsub <- paste(month.name[1:10], j)
        #...
        tmp <- data.frame(datasub,factorsub=factor(factorsub, levels=unique(factorsub)))
        tt <- qplot(factorsub, datasub, data=tmp, geom = "boxplot", ylab='Chg', xlab='Hours', main=j)

        myplotlist[[nCount]] <- tt

}

my.multiplot(plotlist=myplotlist,cols=3)

--- end of modified R script

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Michael
> Sent: Wednesday, December 07, 2011 3:30 PM
> To: Tengfei Yin
> Cc: r-help
> Subject: Re: [R] Help! I couldn't put multiple qplot on the same page...
>
> Still the same problem - in the final aggregated plots, all the titles
> are diffrent(which is good), but the curve shapes are the same...
>
> How could this happen?
>
> Is this a bug?
>
> On 12/7/11, Tengfei Yin <[hidden email]> wrote:
> > library(gridExtra)
> > ?grid.arrange
> >
> > I found this function convenient to me, it could arrange multiple ggplot
> > object on the same view window
> > p1 <- qplot(...)
> > p2 <- qplot(...)
> > ....
> > grid.arrange(p1, p2, ..., nrow = 2)
> >
> > different from your design, but for the same purpose I guess.
> >
> > cheers
> >
> > Tengfei
> >
> > On Wed, Dec 7, 2011 at 5:08 PM, Michael <[hidden email]> wrote:
> >
> >> Thanks a lot!
> >>
> >> Now I can see the individual plot, but still not the
> >> originally-desired multi-plot-on-one-page?
> >>
> >> Any thoughts? Thanks again!
> >>
> >> On 12/7/11, Yihui Xie <[hidden email]> wrote:
> >> > This is probably one of the most frequently asked questions. The
> >> > answer is to print() the objects. See R FAQ 7.22.
> >> >
> >> >
> >> http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f
> >> >
> >> > Regards,
> >> > Yihui
> >> > --
> >> > Yihui Xie <[hidden email]>
> >> > Phone: 515-294-2465 Web: http://yihui.name
> >> > Department of Statistics, Iowa State University
> >> > 2215 Snedecor Hall, Ames, IA
> >> >
> >> >
> >> >
> >> > On Wed, Dec 7, 2011 at 4:38 PM, Michael <[hidden email]> wrote:
> >> >> I found that if I run each "qplot" manually it would plot out
> >> something...
> >> >>
> >> >> but if I put it into the loop,
> >> >>
> >> >> it just doesn't work at all - sometimes it refused to plot anything...
> >> >>
> >> >
> >>
> >> ______________________________________________
> >> [hidden email] 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.
> >>
> >
> >
> >
> > --
> > Tengfei Yin
> > MCDB PhD student
> > 1620 Howe Hall, 2274,
> > Iowa State University
> > Ames, IA,50011-2274
> > Homepage: www.tengfei.name
> >
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Help! I couldn't put multiple qplot on the same page...

Yihui Xie-2
In reply to this post by LosemindL
The two plots are in two PDF files, and I said I cheated via LaTeX,
i.e. nothing but putting two \includegraphics{} commands in the same
paragraph.

Regards,
Yihui
--
Yihui Xie <[hidden email]>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Wed, Dec 7, 2011 at 5:23 PM, Michael <[hidden email]> wrote:

> Very surprisingly in the generated multi-plot-on-the-same-page, the
> titles of the sub-plots are different... but their contents are the
> same(ie. the plotted curves are the same)...
>
> How could this happen?
>
> Any thoughts?
>
> On 12/7/11, Yihui Xie <[hidden email]> wrote:
>> This is another frequently asked question about ggplot2, but I don't
>> know. What I can tell you is, if you use Sweave, you probably can
>> consider the knitr package, which enables you to put any plots on one
>> "page" (yes, I'm cheating via LaTeX); see Figure 1 in the manual:
>> https://github.com/downloads/yihui/knitr/knitr-manual.pdf
>>
>> Regards,
>> Yihui
>> --
>> Yihui Xie <[hidden email]>
>> Phone: 515-294-2465 Web: http://yihui.name
>> Department of Statistics, Iowa State University
>> 2215 Snedecor Hall, Ames, IA
>>

______________________________________________
[hidden email] 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.