similar to: adding a reference line to an xyplot

Displaying 20 results from an estimated 10000 matches similar to: "adding a reference line to an xyplot"

2008 Aug 07
2
lattice: add vertical lines in xyplot
Hi list, This is a very basic question about lattice: I wish to add some vertical lines in each panel of a xyplot as demonstrated in this example: > library(lattice) > > xx <- seq(1, 10, length=100) > x <- rep(xx, 4) > y <- c(cos(xx), sin(xx), xx, xx^2/10) > fact <- factor(rep(c("cos", "sin", "id", "square"), each=100))
2008 Nov 15
1
Lattice: groups and no groups with panel.superpose
Dear R listers, I am trying to create a lattice plot with independent regression lines per group for each panel, plus one overall regression line per panel. I succeed in having the separate regression lines for each group per panel, but I can't figure out how to add the overall regression line over all groups. I have learnt a lot from the list, but I can't find an example for what I want
2008 Aug 08
1
Lattice: regression lines within grouped xyplot panels
Dear community, I am looking for a possibility to draw 'regression lines' instead of 'smooth' lines in grouped xyplots. The following code should give you a small example of the data structure. library(lattice) data(Gcsemv, package = "mlmRev") # Creates artificial grouping variable ... Gcsemv$Groups <- ifelse(as.numeric(as.character(Gcsemv$school))>65000,
2009 Mar 23
1
using xyplot
Dear R-sians! I am trying generate a bunch of xyplots library(lattice) myPanel <- function(x,y,xl=range(x),yl=range(y),...) { panel.xyplot(x,y, pch=20,col='blue',cex=0.7,xlim=xl,ylim=yl,...) panel.abline(v=0, col='gray30',lty=2,lwd=1.5,...) panel.loess(x,y, span=2/3,family='gaussian',normalize=T,col='red',lwd=1.5,...) #
2003 Jan 20
2
Adding reference lines to xyplot
I'm trying to add a set of reference lines to a multipanel xyplot xyplot(y ~ x | Visit, panel = function(x, y, ...){ panel.xyplot(x, y, ...) abline(v = c(0.5, 1)) }) However, the reference lines are different for different visits. For example, for the first 2 visits, I'd like vertical lines at x = 0.5 and 1. For visits 3 and four, I'd like vertical lines at x = 1 and 1.5. I can
2005 Apr 12
2
abline() with xyplot()
Hello all, I'm a new user on R, and I used the abline function to draw a line on my graph but it doesn't work with xyplot(). With the plot function, abline() is ok but with plot it doesn't make what I want. Maybe it's a little thing to change in plot() but I don't find what! With xyplot I write this : Xyplot(m~ordered(l,levels=1),
2006 Jun 08
1
panel.abline and xyplot
Dear All, I am wondering on how to use the abline.xyplot with xyplot such that I will have different vertical lines for each panel. More sepcifically, suppose that the xyplot generates 4 panels defined by the combination of two binary variables: X_1 and X_2. i.e. xyplot(Y ~ Z | X_1*X_2, data = df) I want something like: abline(v = 5) if X_1=0 and X_2 = 0 abline(v =
2010 Dec 09
4
[lattice xyplot] Help needed in help in customizing the panel.abline() function
Hi folks, I need some help in customizing the abline() function to be used in a lattice plot. I have attached a reproducible example below. I need help in the following snippet: disc <- xyplot(cnt_gt50pct_disc ~ week_num|sku_num, data=DF,type = "h",lwd=2,panel = function(...) { panel.abline(v = 8, lty = 2) panel.xyplot(...) }) Is there a way I can give
2008 Aug 07
2
panel.arrows problem in custom panel function
Dear List, I am writing a custom panel function and xyplot method to plot the results of a procrustes analysis from the vegan package. I am having trouble getting the call to panel.arrows to work as I wish when conditioning. The attached file contains the function definitions for the xyplot method and the custom panel and prepanel functions I am using. This example, using data and functions from
2007 Feb 21
3
Different gridlines per panel in xyplot
In the example R script below, horizontal gray gridlines are drawn at y coordinates where the points are drawn with the code: panel.abline(h=y, v=xScale, col.line="gray") How do I change this so that the horizontal gray gridlines are drawn at y coordinates where the y labels are drawn? The challenge is that each panel has different y-ranges (in my real example the y-ranges and
2009 Jul 28
2
xyplot, panel.abline, from, to
All, I'm trying to truncate some lines that are added to an xyplot via panel.abline to allow additional space for inserted text. According to ?panel.abline it seems like "from" and "to" will do the trick but it does not work for the sample code below. Any hints much appreciated. Cheers, David x = seq(1,8) y.1 = .6*x + 3.5 + rnorm(8, 0, .5); y.2 = .4*x + 1 + rnorm(8,0,
2006 Mar 10
1
add trend line to each group of data in: xyplot(y1+y2 ~ x | grp...
Although this should be trivial, I'm having a spot of trouble. I want to make a lattice plot of the format y1+y2 ~ x | grp but then fit a lm to each y variable and add an abline of those models in different colors. If the xyplot followed y~x|grp I would write a panel function as below, but I'm unsure of how to do that with y1 and y2 without reshaping the data before hand. Thoughts
2006 Apr 04
2
xyplot: getting data into the panel function
In xyplot, I would like to get the "data into the panel function" in the following sense: Consider xyplot(scc~time|cowidp, data=cow.s,type=c("l"), panel=function(x,y,subscripts,...){ panel.xyplot(x,y,...) vvv<-cow.s[which(!is.na(cow.s[subscripts,"mastreat"])),"time"] panel.abline(v=vvv,col="red",lwd=2) } ) If I want to use a
2005 Sep 17
4
xyplot and abline
Dear All, I wonderif there is a simple way to draw a regression line in the xyplot: more specifically, let: age <- c(20:30, 31:40 ) age.cut <- cut(age, breaks = 2 ) y<- rnorm(20) x <- rnorm(20,4,1) xyplot(y ~ x| age.cut, xlab="x", ylab="y") How to draw (in the plot given by xyplot) the two regression lines (y ~ x) corresponding to the two category
2009 Sep 07
1
xyplot {lattice} are different types possible for each panel?
Hello R Folks... Using the example below, I¹d like two of the panels to be plotted with type = ³p² but the third to be done with type = ³h². I can¹t use type = c(³p², ³p², ³h²) because this syntax applies all given types to every panel. I don¹t think I can use groups and distribute.type because these are intended for different styles of plotting within a single panel. As you can see, I tried
2011 Nov 10
1
newbie's question : xyplot legend with a white background
Hello, Sorry in advance for adding a silly question on this forum but I haven't found the right keywords to find a solution to this basic problem. I'm just looking a way to have a white background behind the legend to hide the grid. Thanks in advance. The silly example for my silly question: xyplot(1~1, panel = function(x,y, ...) { panel.xyplot(x,y)
2023 Nov 18
1
combine barchart and xyplot in lattice
In below graph, I would like to add two vertical lines using panel.abline(). ?Is this possible? Thanks, Naresh mydf <- data.frame(hour = rep(6:20, 2), traffic = c(round(dnorm(6:20, 9, 3) * 10000), round(dnorm(6:20, 17, 4) * 10000)), direction = rep(c("inbound", "outbound"), c(15, 15))) vehicles <- data.frame(hour = 6:20, count = c(100, 120, 140, 125, 105, 80, 70, 75,
2023 Nov 18
1
combine barchart and xyplot in lattice
On Sat, 18 Nov 2023 at 06:44, Naresh Gurbuxani <naresh_gurbuxani at hotmail.com> wrote: > > In below graph, I would like to add two vertical lines using > panel.abline(). Is this possible? I assume you want the 'v' variable in panel.abline() to be interpreted in the context of your x-axis, which here represents a factor variable. Unless two factor variables have the same
2009 Sep 03
1
putting reference lines or grids into the background of a plot
Dear R-community, using R.2.9.1, how do you put reference lines or grids into the _background_ of a plot? For example: barplot(3:1) abline(h = seq(0.5, 2.5 ,0.5), col = "red", lty = "dashed") -> The lines are before the bars (and the line parts going through the bars might be considered as "chart junk", I suppose). Now, in this toy example I could just do the
2006 Jun 15
1
xyplot problem
Dear all, I have created the following data (that you can run) in order to explain my problem: y <- rep(c(1,2), 8) id <- rep(1:8,each=2) x1 <- rep(c("-a","+a"), each = 8) x2 <- rep(c("-b","+b"), each = 2, times = 4) x3 <- rep(c("-c", "+c"), each = 4,2) df <- data.frame(cbind(id,y,x1,x2,x3)) If I do: