[R] Error when using plot in diag.panel argument of pairs

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat Jul 2 16:36:17 CEST 2011

If you send a better readable message with really reproducible code, we 
may provide a solution, this way it is really hard to read your code. 
And yes, please do not send html mail. My guess is that par(new=TRUE) 
will help, but I do not want to construct the examples at first.

On 02.07.2011 14:37, "Patrick Großmann" wrote:
>   Dear Madame or Sir,I am having a problem in combining density-smoothed scatterplot matrices with a plot of kernel destiny estimations of each dimension plotted on the respective field of the diagonal.I have tried following approach using the package "sm" for the kernel density estimation, as well as "MASS" respectively:pairs(myTable[, 1:4],panel=function(x,y, ...){     xy=kde2d(x,y)     image(xy, add=TRUE)},diag.panel = function(x,...){plot(density(x), add = TRUE)#boxplot(x, add = TRUE)})where myTable is an ordinary table I am using the first four columns of. Unfortunately this produces an error stating that plot has created a new plot. I suppose this is the same situation when forgetting "add  = TRUE" with plotting functions such as boxplot (as in my code used with "boxplot(x, add = TRUE)" ) or any other (e.g. smoothScatter). Analyzing the partial plot,  which can be seen before R rejects my code, I come to the conclusion that add might not be a valid argument for "plot
". My questions therefore is, whether there is an option to plot the result of the 1d kernel density estimation to the diagonal of the scatterplot produced by pairs or which plot function is valid in this case. So basically I would like to generate the same output I am able to produce with boxplots on the diagonal with a density estimation.Additional question: I bet there is an opportunity to include both the boxplot and the kernel density estimation on each field of the diagonal (as I saw before in a published paper), but I just could not figure out how to "overdraw". Maybe you could give me a slight idea (reference would be fine, too) on how to achieve this. I would be highly thankful!Kind regards and many thanks in advance,-Patrick Grossman --
> Patrick Großmann - HiWi zur Netzwerkdokumentation
> Network Operation Center    NOC
> Hochschulrechenzentrum    HRZ    Universität Bielefeld
> Büro:
> UHG V0-251
> Telefon:
> +49 521 106-12618
> Fax:
> +49 521 106-2969
> Telefon Sekretariat:
> +49 521 106-4951
> http://www.uni-bielefeld.de/hrz/
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org 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.

More information about the R-help mailing list