Skip to content

R: Error in plot.new() : axis style "d" not implemented

8 messages · Hinnerk Boriss, Peter Dalgaard, Uwe Ligges +3 more

#
Hi there!

Both on windows and Solaris platforms I run into troubles when trying to
draw two plots on top of each other. Here a short code example:
Error in plot.new() : axis style "d" unimplemented
And here an excerpt from the R help pages: 
xaxs
The style of axis interval calculation to be used for the x-axis.
Possible values are "r", "i", "e", "s", "d". The styles are generally
controlled by the range of data or xlim, if given. Style "r" (regular)
first extends the data range by 4 percent and then finds an axis with
pretty labels that fits within the range. Style "i" (internal) just
finds an axis with pretty labels that fits within the original data
range. Style "s" (standard) finds an axis with pretty labels within
which the original data range fits. Style "e" (extended) is like style
"s", except that it is also ensured that there is room for plotting
symbols within the bounding box. Style "d" (direct) specifies that the
current axis should be used on subsequent plots. (Only "r" and "i"
styles are currently implemented) 

As I understand the manual pages, this should work. However it doesn't. 

Is there any other way to combine plots and align them on the same axis?
I hope someone can help.

Cheers,
Hinnerk

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
"Hinnerk Boriss" <boriss at izbi.uni-leipzig.de> writes:
....
Which part of 'Only "r" and "i"' did you misunderstand if you expect
"d" to work? 

Patches will be considered....
#
Hinnerk Boriss wrote:
Please read the last sentence you cited --- right, the one in brackets!
It means: "d" is NOT implemented.
Try points(x2, y2) instead of the second call to plot().
Maybe you need to scale the axes in the first call to plot(), or e.g.
like:

 plot(c(x1, x2), c(y1, y2), type = "n")
 points(x1, y1)
 points(x2, y2)

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
1 day later
#
Hi!

Is there a way to evaluate "density" objects other than with plot, so
that I can write data points to a file and plot them with gnuplot? Can
anyone help?

Cheers,
Hinnerk

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Thursday 14 November 2002 06:11 am, Hinnerk Boriss wrote:
Value:

     If `give.Rkern' is true, the number R(K), otherwise an object with
     class `"density"' whose underlying structure is a list containing
     the following components.

       x: the `n' coordinates of the points where the density is
          estimated.

       y: the estimated density values.

      ...

That should be enough, shouldn't it ?

Deepayan

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Thu, 14 Nov 2002, Hinnerk Boriss wrote:

            
?density tells you

Value:

     If `give.Rkern' is true, the number R(K), otherwise an object with
     class `"density"' whose underlying structure is a list containing
     the following components.

       x: the `n' coordinates of the points where the density is
          estimated.

       y: the estimated density values.

...

so you could for example do

dens <- density(...)
write.table(data.frame(x=dens$x, y=dens$y), "somefile")

I have no idea why anyone would want to plot in gnuplot rather than in R,
and hence don't know what formats gnuplot accepts.
#
density() returns a list containing the x and y values of the density.  

dens <- density(x)
write(t(cbind(dens$x, dens$y)), file = "gnuplot-input.txt")

-roger
_______________________________
UCLA Department of Statistics
rpeng at stat.ucla.edu
http://www.stat.ucla.edu/~rpeng
On Thu, 14 Nov 2002, Hinnerk Boriss wrote:

            
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Thanks for all the suggestions!
The point is that I want to plot many densities in one graph. I can do
that with R using par(new=T), but I cannot print those graphs. 

Thus, I wonder if I could also apply (lapply) density(...) to a vector
of x-values, to get a my different density functions evaluated all at
the same x. Then, I should be able to write a file that looks like:

X dens1(X) dens2(X) ...

Can anyone help?

Cheers,
Hinnerk

 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._