Hello Everyone I have the data long format and I want to draw the contour plot with it x1 x2 x3 0 1 2 0 2 1 0 3 5 1 1 4 1 2 2 1 3 3 when I am using contour(x1,x2,x3,col=heat.colors) or fill.contour its giving me an error that increasing x and y expected So please tell me what is the right function to draw contour when the data is not ordered and you cant order it. [[alternative HTML version deleted]]
Hello, Follow the code below and see what's the right way: d <- read.table(text=" x1 x2 x3 0 1 2 0 2 1 0 3 5 1 1 4 1 2 2 1 3 3 ", header=TRUE) x3 <- matrix(d[, "x3"], ncol=2) levels <- sort(unique(x3)) contour(0:1, 1:3, t(x3), levels=levels) Hope this helps, Rui Barradas Em 18-07-2012 10:23, Akhil dua escreveu:> Hello Everyone > > I have the data long format and I want to draw the contour plot with it > > x1 x2 x3 > 0 1 2 > 0 2 1 > 0 3 5 > 1 1 4 > 1 2 2 > 1 3 3 > > > when I am using contour(x1,x2,x3,col=heat.colors) or fill.contour > its giving me an error that increasing x and y expected > > > So please tell me what is the right function to draw contour when the data > is not ordered and you cant order it. > > [[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. >
Hi Akhil, in addition to Rui's post, here is a solution using lattice graphics. tmp<-read.table(textConnection("x1 x2 x3 0 1 2 0 2 1 0 3 5 1 1 4 1 2 2 1 3 3"),header=T) library(lattice) contourplot(x3~x1*x2,tmp) hth. Am 18.07.2012 11:23, schrieb Akhil dua:> Hello Everyone > > I have the data long format and I want to draw the contour plot with it > > x1 x2 x3 > 0 1 2 > 0 2 1 > 0 3 5 > 1 1 4 > 1 2 2 > 1 3 3 > > > when I am using contour(x1,x2,x3,col=heat.colors) or fill.contour > its giving me an error that increasing x and y expected > > > So please tell me what is the right function to draw contour when the data > is not ordered and you cant order it. > > [[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. >-- Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Pflichtangaben gem?? Gesetz ?ber elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. Alexander Kirstein, Joachim Pr?l?, Prof. Dr. Dr. Uwe Koch-Gromus
Hello, Now I don't understand. Inline Em 18-07-2012 11:56, Akhil dua escreveu:> why are you writing ncol=2 ? > > I have levels=100 for x1 and the x1 is my z matrix >In your contour instruction x3 is the z matrix, not x1. And your dataset shows a 2x3 grid, hence ncol=2, for (x1 times x2) 0:1x1:3. Also, see Eik's post, lattic graphics clearly are more intuitive. Rui Barradas> > > On Wed, Jul 18, 2012 at 3:46 PM, Rui Barradas <ruipbarradas at sapo.pt > <mailto:ruipbarradas at sapo.pt>> wrote: > > Hello, > > Follow the code below and see what's the right way: > > > d <- read.table(text=" > > x1 x2 x3 > 0 1 2 > 0 2 1 > 0 3 5 > 1 1 4 > 1 2 2 > 1 3 3 > ", header=TRUE) > > x3 <- matrix(d[, "x3"], ncol=2) > levels <- sort(unique(x3)) > contour(0:1, 1:3, t(x3), levels=levels) > > > Hope this helps, > > Rui Barradas > > Em 18-07-2012 10:23, Akhil dua escreveu: > > Hello Everyone > > I have the data long format and I want to draw the contour plot > with it > > x1 x2 x3 > 0 1 2 > 0 2 1 > 0 3 5 > 1 1 4 > 1 2 2 > 1 3 3 > > > when I am using contour(x1,x2,x3,col=heat.__colors) or fill.contour > its giving me an error that increasing x and y expected > > > So please tell me what is the right function to draw contour > when the data > is not ordered and you cant order it. > > [[alternative HTML version deleted]] > > ________________________________________________ > R-help at r-project.org <mailto:R-help at r-project.org> mailing list > https://stat.ethz.ch/mailman/__listinfo/r-help > <https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do read the posting guide > http://www.R-project.org/__posting-guide.html > <http://www.R-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > > >
Hello every one can any one tell me how to draw contour with this data set c z shock 1 0.45450237 0 2 0.02663337 0 3 -2.08444556 0 4 -0.12715275 0 5 0.67066360 0 6 -0.73540081 0 I want to draw contour for shock i.e my z matrix is shock when I am applying contour its giving me error : increasing x and y are expected when I am applying contourplot its giving me error : no applicable method for contour plot applied to an object of class "c('double','numeric')" [[alternative HTML version deleted]]