Learn R Programming

RPMG (version 2.2-7)

jpng: png or pdf output

Description

Get file name and recreate plot on a png or pdf device. This program makes an attempt to keep the same size plot as viewed in the screen.

Usage

jpng(file='tmp',  width = 8, height = 8,P = NULL,  bg = "white")
jpdf(file='tmp',  width = 8, height = 8,P = NULL)

Value

Graphical Side Effect

Arguments

file

png or pdf: will be added as a suffix, if needed

width

width, inches

height

height, inches

P

vector to fix the size, c(width, height)

bg

background color (default="transparent")

Author

Jonathan M. Lees<jonathan.lees.edu>

Details

If P=c(10,12) is missing or NULL, program will attempt to use current plotting region via par to duplicated the size of the postscript device. Must close this device with dev.off() to finish. If either w or h are provided they will override the values in vector P.

If the standard suffix (png or pdf) are provided the file will be set. If these are omitted, they will be added to the given name according to the local.file function.

See Also

par, postscript, device

Examples

Run this code

if (FALSE) {
jjj = local.file('hi', 'png')
x= rnorm(10)
y= rnorm(10)

plot(x,y)

print('resize the current plot')

jpng(jjj, width = 8, height = 8)
plot(x,y)
dev.off()

jpdf("HiThere.pdf", width = 8, height = 8 )
plot(x,y)
dev.off()


jpng("HiThere.png", width = 8, height = 8 , bg='red' )
plot(x,y)
dev.off()

}



Run the code above in your browser using DataLab