Hi, sorry for bothering your guys. I will trying to make some nice graph using boxplot. when I check the help file of boxplot, there is a sample code as: boxplot(len ~ dose, data = ToothGrowth, add = TRUE, boxwex = 0.25, at = 1:3 + 0.2, subset = supp == "OJ", col = "orange") legend(2, 9, c("Ascorbic acid", "Orange juice"), fill = c("yellow", "orange")) But when I run it, it shows the following error: Error in xypolygon(xx, yy, lty = "blank", col = boxfill[i]) : plot.new has not been called yet what does it mean? If I first run "plot.new()", then running the above code, only the x-axis and y-axis is on the graph, no boxplot inside. Can anyone tell me how to call plot.new or at least how to run the above code correctly? Thank you very much! -- View this message in context: http://www.nabble.com/About-%22Plot.new%22-tp19446258p19446258.html Sent from the R help mailing list archive at Nabble.com.
You can't add=TRUE unless the graph exists in the first place. So, drop that if you're creating the graph. Or if that's there because you want to put a boxplot on top of a preexisting graph, make sure you have created the preexisting graph already. --Adam On Thu, 11 Sep 2008, cathelf wrote:> > Hi, sorry for bothering your guys. > I will trying to make some nice graph using boxplot. when I check the help > file of boxplot, there is a sample code as: > > boxplot(len ~ dose, data = ToothGrowth, add = TRUE, > boxwex = 0.25, at = 1:3 + 0.2, > subset = supp == "OJ", col = "orange") > legend(2, 9, c("Ascorbic acid", "Orange juice"), > fill = c("yellow", "orange")) > > But when I run it, it shows the following error: > Error in xypolygon(xx, yy, lty = "blank", col = boxfill[i]) : > plot.new has not been called yet > > > what does it mean? If I first run "plot.new()", then running the above > code, only the x-axis and y-axis is on the graph, no boxplot inside. > > Can anyone tell me how to call plot.new or at least how to run the above > code correctly? > > Thank you very much! > > > -- > View this message in context: http://www.nabble.com/About-%22Plot.new%22-tp19446258p19446258.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >
on 09/11/2008 05:41 PM cathelf wrote:> Hi, sorry for bothering your guys. > I will trying to make some nice graph using boxplot. when I check the help > file of boxplot, there is a sample code as: > > boxplot(len ~ dose, data = ToothGrowth, add = TRUE, > boxwex = 0.25, at = 1:3 + 0.2, > subset = supp == "OJ", col = "orange") > legend(2, 9, c("Ascorbic acid", "Orange juice"), > fill = c("yellow", "orange")) > > But when I run it, it shows the following error: > Error in xypolygon(xx, yy, lty = "blank", col = boxfill[i]) : > plot.new has not been called yet > > > what does it mean? If I first run "plot.new()", then running the above > code, only the x-axis and y-axis is on the graph, no boxplot inside. > > Can anyone tell me how to call plot.new or at least how to run the above > code correctly? > > Thank you very much!You are running the second part one of the examples in ?boxplot, without having run the first part. The use of 'add = TRUE' indicates that you want to add the above boxplot to an existing plot, as is used in the example. Since you have not run the first part of the example, there is no existing boxplot, thus no open graphics device, therefore the error. Either run the full example, or remove the 'add = TRUE'. HTH, Marc Schwartz
@mr.parashar4 - If this not resolved yet, here is what can help plot.new is trying to create a new object out of the standard point plot. I believe you have not created a standard point plot, i.e. in your case, plot(xm,ym). This will show the graphical plot window. Keep that window open and then run your given command. If you have already defined plot(), then just keep that window open. That is when R will find the object and go ahead with the further commands over the plot you specify. Hope this helps. -- View this message in context: http://r.789695.n4.nabble.com/About-Plot-new-tp866862p4632196.html Sent from the R help mailing list archive at Nabble.com.
Perhaps not at all, since you are posting to the R-help list rather than to the original poster of the question. You also forgot to quote the original question as the posting guide asks you to do. Uwe Ligges On 03.06.2012 08:12, czar wrote:> @mr.parashar4 - If this not resolved yet, here is what can help > plot.new is trying to create a new object out of the standard point plot. I > believe you have not created a standard point plot, i.e. in your case, > plot(xm,ym). This will show the graphical plot window. Keep that window open > and then run your given command. > If you have already defined plot(), then just keep that window open. That is > when R will find the object and go ahead with the further commands over the > plot you specify. > Hope this helps. > > -- > View this message in context: http://r.789695.n4.nabble.com/About-Plot-new-tp866862p4632196.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.