[RkWard-devel] comments on plot_options and distribution plots

Prasenjit Kapat kapatp at gmail.com
Fri Feb 2 01:00:23 UTC 2007


@Thomas
> > * Like allow_log or allow_aspect, other parts of plot_options should also
> > have allow_tag options in <external>, for more embedding flexibility.
>
> Should not be a problem. Which ones do you have in mind?

may be allow_xlim and allow_ylim for the moment?

> Well, there is a subtle difference: The current log option takes the log of
> the value. The plot_options log option draws the scale logarithmic.

I am not much aware of R internals, but I would like to know more
about it. Any reference?

> > * Other problem is with xlim. I think this is an issue in R. Try the
> > following R code:
> >     plot (function (x) dbinom (x, size = 12, prob=0.5000), from=0, to=12,
> > n=13, type="p",xlim=c (2, 8))
> > It gives an error with 'xlog' !
>
> Oh dear. What is that supposed to mean? This does look like some sort of bug
> in plot, since actually plot.function seems to be quite happy to take both a
> from/to and xlim.
> This works, but probably we should not use it:
> graphics:::plot.function (function (x) dbinom (x, size = 12, prob=0.5000,
> log=TRUE), from=0, to=12, n=13, type="p", xlim=c (2,8))

Again, why should we not use it?

>
> This modified plot function will do the trick, too (removed the y parameter
> from the call to plot.function, but I don't understand, what it was supposed
> to do):
> "plot2" <- function (x, y, ...)
> {
>     if (is.null(attr(x, "class")) && is.function(x)) {
>         nms <- names(list(...))
>         if (missing(y))
>             y <- {
>                 if (!"from" %in% nms)
>                   0
>                 else if (!"to" %in% nms)
>                   1
>                 else if (!"xlim" %in% nms)
>                   NULL
>             }
>         if ("ylab" %in% nms)
>             plot.function(x, ...)
>         else plot.function(x, ylab = paste(deparse(substitute(x)),
>             "(x)"), ...)
>     }
>     else UseMethod("plot")
> }
>
> So this does look like a bug in R, IMO. Do you feel like posting a message
> about that to r-help AT r-project.org? Else I'll do so, but not sure, when
> I'll get around to.

I have reported this problem to r-help with your code, let us see what
they reply!

> > In the light of the plot_options, I think
> > it will be better to go back to:
> >
> > x = seq(from=0,to=12,length=13)
> > y = dbinom(x,size=12,prob=0.5)
> > plot(x=x,y=y<? getRK ("plotoptions.code.printout"); ?>)
>
> Hmm. Not too pretty, if we can avoid it. I suggest delay using the
> plot_options plugin for now (or disable the xlim/ylim for now; I can add an
> option for that). Let's see, what the R people have to say about this, first.

Well if you add the allow_xlim and allow_ylim then I can include
plot_option by setting allow_{xlim,ylim,log} to false. But again, I
fail to understand the technical details of why using
plot(x=x,y=y<?..?>) is to be avoided?

Regards
PK




More information about the Rkward-devel mailing list