[R] About "Plot.new"
marc_schwartz at comcast.net
Fri Sep 12 00:51:29 CEST 2008
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'.
More information about the R-help