Re: [R] Vertical line in densityplot?
On 12/1/06, Thomas Petzoldt [EMAIL PROTECTED] wrote: Hi, lattice graphics work by utilizing so called panel functions. Here is a working version of your example: library(lattice) x-rnorm(100) plot.new() densityplot(x, panel=function(x, ...){ panel.densityplot(x, ...) panel.abline(v=0) } ) For mor information, please look into the examples of densityplot and the help file of panel.abline Hope it helps Thomas Thank you very much! Lattice works somewhat different from regular graphics step-by-step addition then. With standard axis, I just meant a set of axis where the x and y axis are represented by lines going through origo, or (0,0). Right now some sort of box is used instead. Thanks again! /Gustaf -- email:[EMAIL PROTECTED] tel: +46(0)703051451 address: Kantorsgatan 50:190 75424 Uppsala Sweden __ R-help@stat.math.ethz.ch mailing list 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.
[R] Vertical line in densityplot?
Hi all, I'm trying to get a vertical line at a specific point in a densityplot. abline seems to be what's required, but it doesn't align itself to the scale used in the plot. example: library(lattice) x-rnorm(100) plot.new() densityplot(x) abline(v=0) - The line seems to use some other coordinate system. What kind of call do I use to make abline use the graph's coordinates? Additionally, it would be nice to have standard xy-axis, and to have the line stop at the x-axis, so if anyone could tell me how to do that, I'd be grateful. Thanks in advance, Gustaf PS: a minor question: Why do I have to call plot.new() for abline to work? -- email:[EMAIL PROTECTED] tel: +46(0)703051451 address: Kantorsgatan 50:190 75424 Uppsala Sweden __ R-help@stat.math.ethz.ch mailing list 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.
[R] Vertical line in densityplot?
I think that you are mixing lattice and base graphics. This works for me: library(lattice) x-rnorm(100) densityplot(x, panel = function(x, ...) { panel.densityplot(x, ...) panel.abline(v = 0, ...) } ) Gustaf Rydevik a écrit Hi all, I'm trying to get a vertical line at a specific point in a densityplot. abline seems to be what's required, but it doesn't align itself to the scale used in the plot. example: library(lattice) x-rnorm(100) plot.new() densityplot(x) abline(v=0) - The line seems to use some other coordinate system. What kind of call do I use to make abline use the graph's coordinates? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list 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.
Re: [R] Vertical line in densityplot?
Hi, lattice graphics work by utilizing so called panel functions. Here is a working version of your example: library(lattice) x-rnorm(100) plot.new() densityplot(x, panel=function(x, ...){ panel.densityplot(x, ...) panel.abline(v=0) } ) For mor information, please look into the examples of densityplot and the help file of panel.abline Hope it helps Thomas Gustaf Rydevik wrote: Hi all, I'm trying to get a vertical line at a specific point in a densityplot. abline seems to be what's required, but it doesn't align itself to the scale used in the plot. example: library(lattice) x-rnorm(100) plot.new() densityplot(x) abline(v=0) - The line seems to use some other coordinate system. What kind of call do I use to make abline use the graph's coordinates? Additionally, it would be nice to have standard xy-axis, and to have the line stop at the x-axis, so if anyone could tell me how to do that, I'd be grateful. What is a standard x achsis?. Thanks in advance, Gustaf PS: a minor question: Why do I have to call plot.new() for abline to work? __ R-help@stat.math.ethz.ch mailing list 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.