Luigi Marongiu
2015-Apr-23 12:50 UTC
[R] create function to plot high density data using lattice
Dear all,
with the most useful help of Duncan I updated a script to plot high
density data in the form of 384 squares containing tiny plots. The
function works and it is possible to create a pdf version of the
output. but when i try to make a function out of this script, the
resulting pdf file is empty.
Any tips?
Thank you and best regards,
Luigi
>>> here is the example:
DF <- data.frame(Y = rnorm(17280),
X = rnorm(1:45),
Y2 = rnorm(17280)+2,
Z = 1:384)
plot.layout <- function(DF) {
# this works from here...
pdf(
file = "TITLE-amp outlook.pdf",
width = 15,
height = 11,
onefile = TRUE,
family = "Helvetica",
paper = "a4r"
)
xyplot(Y ~ X | Z,
data = DF,
groups = Z,
allow.multiple = TRUE,
ylab= "Y VALUES",
xlab="X VALUES",
main="TITLE",
scales = list(
x = list(draw = FALSE),
y = list(draw = FALSE),
relation="same",
alternating=TRUE),
as.table = TRUE,
layout = c(24,16),
par.settings = list(
strip.background=list(col="white"),
axis.text = list(cex = 0.6),
par.xlab.text = list(cex = 0.75),
par.ylab.text = list(cex = 0.75),
par.main.text = list(cex = 0.8),
superpose.symbol = list(type = "l", cex = 1)
),
strip = FALSE,
type = "l",
col = 3,
panel = panel.superpose
)
dev.off()
#... till here
}
plot.layout(DF)
Michael Dewey
2015-Apr-23 13:17 UTC
[R] create function to plot high density data using lattice
I suspect Luigi that if you wrap the call to xyplot in print( ) matters might be improved. On 23/04/2015 13:50, Luigi Marongiu wrote:> Dear all, > with the most useful help of Duncan I updated a script to plot high > density data in the form of 384 squares containing tiny plots. The > function works and it is possible to create a pdf version of the > output. but when i try to make a function out of this script, the > resulting pdf file is empty. > Any tips? > Thank you and best regards, > Luigi > > > >>> here is the example: > > > DF <- data.frame(Y = rnorm(17280), > X = rnorm(1:45), > Y2 = rnorm(17280)+2, > Z = 1:384) > plot.layout <- function(DF) { > > # this works from here... > pdf( > file = "TITLE-amp outlook.pdf", > width = 15, > height = 11, > onefile = TRUE, > family = "Helvetica", > paper = "a4r" > ) > xyplot(Y ~ X | Z, > data = DF, > groups = Z, > allow.multiple = TRUE, > ylab= "Y VALUES", > xlab="X VALUES", > main="TITLE", > scales = list( > x = list(draw = FALSE), > y = list(draw = FALSE), > relation="same", > alternating=TRUE), > as.table = TRUE, > layout = c(24,16), > par.settings = list( > strip.background=list(col="white"), > axis.text = list(cex = 0.6), > par.xlab.text = list(cex = 0.75), > par.ylab.text = list(cex = 0.75), > par.main.text = list(cex = 0.8), > superpose.symbol = list(type = "l", cex = 1) > ), > strip = FALSE, > type = "l", > col = 3, > panel = panel.superpose > ) > dev.off() > #... till here > > } > plot.layout(DF) > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >-- Michael http://www.dewey.myzen.co.uk/home.html