[Rd] screen can't go back to log="y" plot (PR#831)

tov@ece.cmu.edu tov@ece.cmu.edu
Thu, 1 Feb 2001 02:13:12 +0100 (MET)


Prof Brian D Ripley <ripley@stats.ox.ac.uk> writes:

> [I have abbreviated the subject as jitterbug has been having probems
> with long subjects.]
> 
> The issue here is that one cannot mix log/non-log axes in the calls to
> screen(), as the appropriate par() parameter is read-only, but the
> meaning of yaxp depends on it.  But beyond that you can't set
> x/yaxp for log axes.
> 
> You should be able to do this: you can in the S original.
> 
> A simpler version:
> 
> plot (1:2, 1:2, log="y", main="1")
> zz <- par("yaxp")
> zz
> [1]  1  2 -5
> par(yaxp=zz)
> Error in par(yaxp = zz) : invalid value specified for graphics parameter
> "yaxp".
> 
> So you can't reset the yaxp parameter to what it is reported as!
[snip]

The code in main/par.c ignores the value of xlog (or ylog) when
setting xaxp (or yaxp).  Right now you have in Specify (and Specify2):

... else if (streql(what, "xaxp")) {
	value = coerceVector(value, REALSXP);
	lengthCheck(what, value, 3);
	naRealCheck(REAL(value)[0], what);
	naRealCheck(REAL(value)[1], what);
        posIntCheck((int) (REAL(value)[2]), what);

Shouldn't that be something like:

... else if (streql(what, "xaxp")) {
	value = coerceVector(value, REALSXP);
	lengthCheck(what, value, 3);
	naRealCheck(REAL(value)[0], what);
	naRealCheck(REAL(value)[1], what);
        if (dd->gp.xlog)
            logAxpCheck((int) (REAL(value)[2]), what);
        else
            posIntCheck((int) (REAL(value)[2]), what);

Where logAxpCheck is suitably defined as:

static void logAxpCheck(int x, char *s)
{
    if (x == NA_INTEGER || x == 0 || x > 4)
	par_error(s);
}

since only values < 0 or the values 1, 2, 3 are allowed?


> Additional bug: the meaning of x/yaxp for log axes is not defined
> in help(par).

excerpt from help(par):

    xaxp: A vector of the form `c(x1, x2, n)' giving the coordinates
          of the extreme tick marks and the number of intervals
          between tick-marks.

Could you add:

          The value of n must be positive for linear scale axes.  For
          logarithmic scale axes n must be either negative (then there
          will be (1-n) ticks at a linear distance) or one of 1, 2, or
          3 where n then indicates the number of ticks per decade.

similar for yaxp?  What am I missing?
Regards,
  -tom

-- 
mailto:tov@ece.cmu.edu (Tom Vogels)   Tel: (412) 268-6638   FAX: -3204

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._