Multiple plot jpeg file

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

Multiple plot jpeg file

Bill Hunsicker

R-Help,

I am executing a R script and would like to put multiple plots into a
single file. For some reason the contents of plotfile.jpg always seem to
contain the last plot and not all plots.

If I do same thing with pdf, a multiple plot file is created.

Can you help me?

Regards,
Bill



Bill Hunsicker
RF Micro Devices
7625 Thorndike Road
Greensboro, NC 27409-9421
[hidden email]
336-678-5260(w)
336-207-3895(m)
336-678-5088(lab)

______________________________________________
[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: Multiple plot jpeg file

Marc Schwartz


On Tue, 2007-06-19 at 15:39 -0400, Bill Hunsicker wrote:

> R-Help,
>
> I am executing a R script and would like to put multiple plots into a
> single file. For some reason the contents of plotfile.jpg always seem to
> contain the last plot and not all plots.
>
> If I do same thing with pdf, a multiple plot file is created.
>
> Can you help me?
>
> Regards,
> Bill

There is no notion of a 'page' in bitmapped devices as there is with PDF
or PS devices. Thus, each time you call plot(...) with a bitmapped
device, the previous output is lost.

If you want multiple plots in a bitmapped device, you would need to use
layout() or par(mfrow/mfcol) to define multiple plot regions within the
overall bitmapped output.

For example:

jpeg("test.jpg", 400, 400)

# Set for 2 rows, 1 col
par(mfrow = c(2, 1))

# Set the margins to make room
par(mar = c(1, 4, 4, 2))

# Draw a barplot
barplot(1:5)

# Set the margins to make room
par(mar = c(5, 4, 1, 2))

# Do a scatterplot
plot(1:10)

# Close the device
dev.off()


Adjust other pars as required.

See ?par and ?layout

HTH,

Marc Schwartz

______________________________________________
[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: Multiple plot jpeg file

Prof Brian Ripley
On Tue, 19 Jun 2007, Marc Schwartz wrote:

>
>
> On Tue, 2007-06-19 at 15:39 -0400, Bill Hunsicker wrote:
>> R-Help,
>>
>> I am executing a R script and would like to put multiple plots into a
>> single file. For some reason the contents of plotfile.jpg always seem to
>> contain the last plot and not all plots.
>>
>> If I do same thing with pdf, a multiple plot file is created.
>>
>> Can you help me?
>>
>> Regards,
>> Bill
>
> There is no notion of a 'page' in bitmapped devices as there is with PDF
> or PS devices. Thus, each time you call plot(...) with a bitmapped
> device, the previous output is lost.

But there is a concept of multiple pages in separate files and that is the
default, Rplot001.jpg, Rplot002.jpg and so on.

The JPEG format only supports one 'page' per file.

> If you want multiple plots in a bitmapped device, you would need to use
> layout() or par(mfrow/mfcol) to define multiple plot regions within the
> overall bitmapped output.
>
> For example:
>
> jpeg("test.jpg", 400, 400)
>
> # Set for 2 rows, 1 col
> par(mfrow = c(2, 1))
>
> # Set the margins to make room
> par(mar = c(1, 4, 4, 2))
>
> # Draw a barplot
> barplot(1:5)
>
> # Set the margins to make room
> par(mar = c(5, 4, 1, 2))
>
> # Do a scatterplot
> plot(1:10)
>
> # Close the device
> dev.off()
>
>
> Adjust other pars as required.
>
> See ?par and ?layout
>
> HTH,
>
> Marc Schwartz
>
> ______________________________________________
> [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.
>

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[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: Multiple plot jpeg file

Marc Schwartz
On Tue, 2007-06-19 at 21:09 +0100, Prof Brian Ripley wrote:

> On Tue, 19 Jun 2007, Marc Schwartz wrote:
>
> >
> >
> > On Tue, 2007-06-19 at 15:39 -0400, Bill Hunsicker wrote:
> >> R-Help,
> >>
> >> I am executing a R script and would like to put multiple plots into a
> >> single file. For some reason the contents of plotfile.jpg always seem to
> >> contain the last plot and not all plots.
> >>
> >> If I do same thing with pdf, a multiple plot file is created.
> >>
> >> Can you help me?
> >>
> >> Regards,
> >> Bill
> >
> > There is no notion of a 'page' in bitmapped devices as there is with PDF
> > or PS devices. Thus, each time you call plot(...) with a bitmapped
> > device, the previous output is lost.
>
> But there is a concept of multiple pages in separate files and that is the
> default, Rplot001.jpg, Rplot002.jpg and so on.
>
> The JPEG format only supports one 'page' per file

Quite true.  I thinking of 'pages' in the context of a PDF or PS file,
as Bill had noted above and contrasting that with a bitmapped image of a
defined finite 2D pixel space.

Thanks for clarifying.

Regards,

Marc

______________________________________________
[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.