Displaying 20 results from an estimated 30000 matches similar to: "lattice: plotting in a loop"
2009 Jan 16
1
XYplot in Lattice Package
Dear R-Users
I have 2 questions to do with XYplot.
1)
I am trying to use the XYplot function to generate multiple line graphs with
the legend outside the plot.
I am using the following loop for each graph:
library(lattice)
for (i in x.sp){
xyplot(Catch~Year, df, groups = Stock, type="a",auto.key =
list(space = "top", points = FALSE, lines = TRUE,columns = 4))
}
2010 Apr 04
2
One question about saving graph by using xyplot
Hey, folk.
I am trying to get many figures by using the function "xyplot" in the library "lattice". I tried to using the loop to finish it quickly. But I cannot open the saved file after I run the program. But if I use the function "plot" to get other simply figures, it can work. So I want to ask how I can get the saved figures by using "xyplot".
The
2010 Feb 17
2
Problems with xyplot
Hello
I wonder whether someone can tell me what I am doing wrong. Here is the
code (from Bayesian Computation with R - Chapter 2.3.R) that I am trying to
run
####################################
# Section 2.3 Using a Discrete Prior
####################################
graphics.off() # Close all graphics
rm(list=ls()) # Clear all variables
library(LearnBayes)
2004 Dec 10
1
lattice graphics empty in Sweave
Hello,
I have problems using lattice graphics together with Sweave under
Windows XP and R 2.0.0; 2.0.1 Patched; 2.1.0 devel respectively.
Base graphics are o.k., but for lattice graphics empty files (.eps and
.pdf) are generated.
The only workaround I found was to write and read the respective figures
explicitely using postscript() and includegraphics{}.
Have I missed something to solve this
2007 Feb 14
1
lattice graphics and source()
Hi,
I am trying the lattice graphics in R. Let's say, such a little
experiment in file myprog.r:
f <- function(){
x <- 1:10
y <- x^2
xyplot(y ~ x)
}
f()
Then I run the program:
> source("myprog.r")
but nothing happens. Manully run f() at the command line:
> f()
then the figure is shown. This seems to be a bug only associated with
lattice graphics, the
2009 Oct 15
1
Lattice package - Trellis
Hi,
I was trying to make a graph using trellis, and my code is:
-----------------------------------------------------------------
library(lattice)
makeGraph <- function(){
trellis.device()
tbg <- trellis.par.get("background")
tbg$col <- "white"
trellis.par.set("background",tbg)
# Test Data
mfr <- matrix(sample(1:100,50,replace=T),ncol=2)
2009 Feb 05
1
Problem with plotting data from within a function
Dear List,
I try to develop code where plotting functions are embeded in my own
functions. The following is simplified example:
> test <- function() {
> data <- data.frame(x=rep(1:2, each=50), y=rnorm(100))
> library(lattice)
> attach(data)
> xyplot(y~x)
> detach()
>}
>test()
As far as I understand R, when test is called this should create one local
2008 Sep 07
2
Corrupted PDF files
I have the following code that when executed from the command line
works properly and produces a proper PDF. When the script is executed,
the PDF produced is considered corrupt. I am using R 2.7.2 on Mac OSX
10.5.4. Thank you in advance for the help!
library(lattice)
pdf(file="CLDiag2.pdf")
xyplot(
CL ~ HT + WT + AGE + CREA + SEX,
data=data2,
outer=TRUE,
2010 Jan 27
1
Problem with xyplot when creating a .png graphic
Hello,
I have the following problem. I have created a couple of scripts to
create .png graphic files from data plots, using the xyplot (lattice)
command. When I refere to the script with source(""), the script will be
red but there is no output file. The scripts work well with the regular
plot command and produce a nice PNG file.
On the other hand if I entre the single commands
2007 Apr 24
2
xyplot source file only work with echo=TRUE
Hi,
I write several xyplot graphics on a source file. When I try to use
source("graphics.R") the source don't work, but if I use
source("graphics.R",echo=T) it work. Generally some commands work without
echo=T, but xyplot dont work. Why it dont work without echo=T? It is possible
to write a source that dont need echo=T on source command?
Thanks
Ronaldo
--
Aluno de
2011 Mar 07
4
png inside loop
hello list! I'm sorry, I just stumbled over this strange behaviour (at
least I am not able to explain the behaviour, therefore I assume it to
be a strange behaviour):
attach(water) # I know, this is not recommended
names(water[3:10])
[1] "temp" "pH" "DO" "BOD" "COD" "no3" "no2" "po4"
for (i in
2008 Jul 01
3
dev.off() inside a function & other glitches
Hi R people
I am using a function to create a pdf device, then send a lot of plots
to it in a loop then a last lattice xyplot (itself within a function)
outside the loop and finally call dev.off() to write to the file.
This works well apart from the fact that the last plot does not get
sent to the file unless I comment out dev.off() and then apply it in
the console afterwards instead:
2006 Jun 13
2
levelplot and source() problems
I have been using levelplot but have had trouble calling it inside
functions - something seems to go wrong when it's not called directly from
the R command prompt. Simplest reproducible example:
$ R --vanilla
> library(lattice)
> levelplot(matrix(1:4,2,2))
- This gives a nice plot in soothing pastel colors.
Now, with a file lptest.r containing 2 lines:
library(lattice)
2009 Sep 18
1
Lattice barplot not wokring in for-loop?
Dear List-Members,
I am plotting a barplot with the lattice package. The code works, but
when I execute the same code in a for-loop
no plot is shown. Can't figure what the problem is.
(Maybe I am missing something here, but I tried it with plot device
pdf, calling windows() or X11(), testing on windows and linux, etc.)
INFO: R version 2.9.1 (2009-06-26) using Windows/RGui
require(lattice)
2008 Dec 05
1
Problems with lattice-histograms or png within loops
Dear R-users,
I have a question concerning the use of lattice plots within for-loops.
I want to create a png file containing a lattice histogram which works out
fine (part 1).
When I loop the whole code, the graphic file does not contain anything (part
2).
I can fix it by wrapping the histogram function into a print command (part
3).
Why is that so? Why can I not loop it directly?
TIA,
Mark
2009 Jan 21
1
Text Outside Lattice Plot
Dear R users
I created the graph at the bottom using xyplot in the lattice package. I
added a title using the main="Title" command in xyplot, however it is
plotted too close to the legend for my liking. To remedy this I increased
the upper margin of the plot using plot(data, position = c(0,0,1,.9)) and
attempted to move "SNA" upwards and to the right. I have tried using a
2009 Jan 27
1
need some lattice help
Hello everybody,
I just started with lattice plots and I was wondering why it behaves different
than expected.
If I generated multiple plots in the past, I just used some code like this:
lapply(..., {
windows()
plot(...)
})
I got multiple windows, each containing one plot.
Now, I tried the same with "levelplot" (instead of "plot") and I see all
windows are created but
2008 Dec 31
2
Lattice trellis.focus() with pdf
Hi,
I have a the code for a plot that works perfectly running in R and
printing to a Quartz object but which doesn't work when I make the
trellis device a pdf.
The code is as follows:
----
trellis.device(device="pdf", new=TRUE)
trellis.par.set(my.theme())
dotplot(Y ~ X | C, groups=G, data=D, layout=c(2,1), ... )
trellis.focus("panel", 1, 1)
for (y in 1:5) {
2003 Feb 03
1
Lattice not plotting within loop
Something I don't understand ... (!)
With the lattice library loaded, I have a loop
for( Z in ... ) {
...
xyplot(y~x | t, xlab=..., ylab=... )
}
and no plot appears on the R graphics device.
However, when I run the commands within {...}
separately for each instance of Z, I get the
plot displayed each time.
So it looks as though "xyplot" is not outputting
to the graphics
2009 May 20
1
combining xYplot with map
I'm using xYplot to create a bubble plot of values that I'd like to
visualize on top of a filled-in map of the coast, but I'm too much of a
lattice (which I understand xYplot is built on) and mapping newbie to
figure out how to begin to make this happen. Below is some sample code
that doesn't work but illustrates my goal. Any pointers anyone has
would be much appreciated.