Displaying 20 results from an estimated 10000 matches similar to: "function with xyplot"
2005 Apr 07
2
newline in lattice axis label
Hi,
I have a 3 panel xyplot with different variables in the y axis. I'm trying
to insert a newline after "Width (cm)," in the ylab argument as in the
example below. My goal is to have the y axis label broken into two lines,
split after the string just mentioned.
plotfun <- function() {
fakedf <- data.frame(A = sample(1:100, 50),
B = rnorm(50),
2011 Feb 25
1
plotmath: how to create a vector of expressions?
Dear expeRts,
I would like to use LaTeX-like symbols in keys via plotmath. Below is a minimal
example. I get:
Error in fun(key = list(x = 0.5, y = 0.8, text = list(list(expression(paste("(", :
first component of text must be vector of labels
What's wrong? How can I create the required vector (of expressions)?
Cheers,
Marius
library(lattice)
val <- matrix(1, nrow = 10, ncol
2007 Oct 16
1
Adding axis lines to splom plots
Hi,
I am trying to produce a 30x30 lattice grid. The 30 variables naturally
fall into three groups of ten and I would like to add thicker axis lines
around these to highlight this. However, I can only do this separately,
so far, and I don't know how to superimpose the grid with the thicker
lines (separating the 10x10 groups) onto the overall grid of all 30x30
plots. I enclose a
2009 Jan 19
0
Error while adding legends to xyplot
Dear All:
Greetings!
I am able to produce an "xyplot" in R; But I am not able to put multiple
legends on it! So for that matter, I have saved the "xyplot" and reproduced
the same using the simple "plot" option. Then using the "legend" option I
successfully placed the require text and its corresponding value over it.
Now, when I try to copy it as a
2012 Dec 12
2
long margin text below lattice plot - how to wrap lines?
Hello,
I've got a lattice plot and need to add text into the bottom margin of the plotting area (below the bottom legend).
This seems to work in principle using grid.arrange, yet the text to be added is rather long. As a consequence, it gets clipped:
require(lattice)
require(grid)
myplot <- xyplot(1~1)
mytext <- textGrob("This is such a very very long text that it goes on forever
2008 Nov 04
1
How to create margin area around a graphic made by xyplot
Hi list,
Does any body know how I can create a margin area around the graphic created
by xyplot (the same thing we do using par in plot function)? I tried
viewport, but does not work.
Here is the code:
==============================================
require(grid)
vp<- viewport(x=.1,y=.1,width=.6,height=.6,just=c("left", "bottom"))
pushViewport(vp)
2010 Jun 23
1
how to print a colored plot in black/white?
Dear expeRts,
shouldn't this...
x <- 1:10
myplot <- xyplot(x~x,col="red")
trellis.device(postscript,color=FALSE,file="plot.ps")
print(myplot)
dev.off()
... give a black/white plot?
Cheers,
Marius
2007 Feb 09
1
How to add the variable name to a qqplot or densityplot in the diagonal of an splom?
splom() doesn't complain here, but writes no names in the diagonal
boxes. What am I missing?
I believe that I need to add something like grid.text(x, ...) to the
diagonal panel, but I don't know how to get it cycle through the
column labels. And should
varname.col = 'blue', varname.cex = 1
be inside the diag.panel() function?
splom(szw[, n], pscales = 0,
diag.panel
2009 Aug 01
3
Transparency and trellis device
Dear R-users,
I am trying to produce trellis (png, or jpeg) graphs with transparent background, but I cannot manage to make that happen. I tried to play around with themes but to no avail. Any advise on the following example will be greatly appreciated:
Thank you
Sebastien
####
library(lattice)
df <- data.frame(a=rep(1:4,4), b=rep(1:4,4), c=rep(1:4,each=4))
settings <- standard.theme()
2011 Jun 01
2
lattice panel fine control
Hello R experts,
what follows is my reproducible example:
mydata<-structure(list(ped.avg = c(335.9, 110.8, 645.7, 638.9, 1468.1,
126.4, 4811.1, 88.5, 868.5, 656.6, 723.6, 654, 2.8, 15, 14.2,
17.5, 15.4, 112.1, 424.7, 18.3, 19.9, 28.6, 25.6, 23.5, 15.4,
27, 62.1, 15.6, 74.6), ped.erst = c(96, 53.2, 615.2, 616.5, 512.9,
56.2, 1851.8, 57.1, 579.5, 613.2, 601.1, 613.6, 1.3, 6.3, 6.5,
6.1,
2005 Oct 03
2
grob questions
If I run the following example from:
http://www.stat.auckland.ac.nz/~paul/grid/doc/grobs.pdf
> grid.newpage()
> pushViewport(viewport(w = 0.5, h = 0.5))
> myplot <- gTree(name = "myplot", children = gList(rectGrob(name = "box",
+ gp = gpar(col = "grey")), xaxisGrob(name = "xaxis")))
> grid.draw(myplot)
>
2007 Aug 01
1
Problem to remove loops in a routine
Dear R-users,
I have written the following code to generate some trellis plots. It
works perfectly fine except that it is quite slow when it is apply to my
typical datasets (over several thousands of lines). I believe the
problem comes from the loops I am using to subset my data.frame. I read
in the archives that the tapply function is often more efficient than a
loop in R. Unfortunately ,
2012 Apr 15
2
xyplot type="l"
Probably a stupidly simple question, but I wouldn't know how to google it:
xyplot(neuro ~ time | UserID, data=data_sub)
creates a proper plot.
However, if I add
type = "l"
the lines do not go first through time1, then time2, then time3 etc but in
about 50% of all subjects the lines go through points seemingly random
(e.g. from 1 to 4 to 2 to 5 to 3).
The lines always start at time
2012 Mar 10
1
Treat Variable as String and a String as variables name
Dear all.
I am having ten variables (let's call the four of them as
Alpha, Beta, Gamma and Delta.....)
For each variable I have to print around 100 (plots). E
So far I was copying paste the code below many times.
pdf(file="DC_Alpha_All.pdf", width=15) # First Variable is treated as string
plot_dc_for_multiple_kapas(Alpha, 4, c(5, 4), coloridx=c(24, 32)) # First Variable is
2009 Apr 04
2
help with formula and data= argument
Sorry for posting this twice, but I still have not solved this problem
and am hoping for some assistance.
I am attempting to write a function that is flexible enough to respond
to the user providing a formula (with a data= argument) or not (similar
to plot(x,y) versus plot(y~x,data=data)). I have found a method to work
with this in a simple case but am having trouble determining how to
2009 Sep 02
1
get function to return object "name"?
Dear list,
I've written a function that plots subjects. Something like:
myplot <- function(subject) { plot(subject) }
Subjects are vectors, e.g. ...
s1 <- c(200,200,190,180)
... and plotting them works fine, e.g. ...
myplot(s1)
Now I want to have "s1" etc appear in the plot title, but I don't know
how to refer to this generically (the object "name"? I tried
2011 Feb 15
0
Relationships between png resolution, axis.text$cex trellis setting, and paddings
Dear R-users,
I was wondering if somebody could shed some light on the relationships
existing between the resolution of a png device, the axis.text$cex trellis
setting, and the paddings of the actual graph. In the following code, I
create a custom trellis theme that set (among other thing) axis.text$cex to
1 instead of the default 0.8. Then a lattice graph is created and exported
to three png
2008 Aug 08
2
gridBase and new.page() / grid.newpage()
Hello all,
I'm trying to write a function using the gridBase package. I'd like
to push several base subplots to a larger plot constructed with grid.
However, I'm having trouble getting consistent results when running
the function when the plotting window (quartz) is closed, when it is
left open and the plot function is repeated to the same window, and
when the output is saved to a
2005 Mar 09
3
function in order to plot the same graph to postscript and pdf
Hi,
I've written a function in order to plot the same graph in a postcript and in
a pdf file. Unfortunately, the second graph is always empty, i.e.:
plot.both <- function{myplot, filename}{
pdf(file=paste(filename, ".pdf", sep=""))
myplot
dev.off()
postscript(file=paste(filename, ".eps", sep=""))
myplot
dev.off()
}
yields in a
2009 May 04
1
ellipsis problem
Hi,
I'm confused about the use of ellipsis in function arguments. I'm trying
to write a wrapper for plot to automate the combination of plot() and
points() calls for a data.frame. Some arguments seem to get passed
through to the inner plot, while others cause an error:
Error in eval(expr, envir, enclos) :
..1 used in an incorrect context, no ... to look in
As a minimal example:
tmp