[RkWard-devel] Distribution plots: not quite right!
Prasenjit Kapat
kapatp at gmail.com
Wed Jan 24 23:06:03 UTC 2007
On Wednesday 24 January 2007 09:29, Thomas Friedrichsmeier wrote:
> Looking at it, the following may be a more elegant way to do it:
>
> try (plot (function (x) <? getRK ("function"); ?> (x, mean = <? getRK
> ("mean"); ?>, sd = <? getRK ("sd"); ?>), from=<? getRK ("min"); ?>, to=<?
> getRK ("max"); ?>), n=<? getRK ("n"); ?>)
>
> (example R code:)
> plot (function (x) dnorm (x, mean=1, sd=1), from=-3, to=3, n=100)
That is indeed an elegant method. Will modify the files accordingly. This is
actually plot.function which is same as the curve() function.
>
> This way we'd get a continuous plot (of course this does not make much
> sense for the discrete distributions, but for the continuous distributions
> it's probably more elegant). To get the current discrete plotting, we'd use
>
> plot (function (x) dnorm (x, mean=1, sd=1), from=-3, to=3, n=100, type="p")
>
> > The xlabel and ylabel may be avoided.
The plot(function(x)..) method takes care of the labels to a decent extent.
Great.
> If you'd volunteer to do this, that would truly be helpful.
No problem. I will do it over this weekend.
> > 3. A better way would be to do a graphics display rather than a R Output,
> > whereby by changing the parameters of the distribution and
> > "re-submitting" the plots can be "dynamically" visialized.
>
> One long term TODO item is a "preview" window for graphs. That's probably
> the only clean solution (if we would simply replace rk.graph.on () by x11
> (), we'd open a new window on each "Submit"; if we would omit
> rk.graph.on/off () altogether, we'd simply plot to whichever device is
> currently active, risking to mess up unrelated graphs), but will require
> some work to implement.
Hmm... I understand your point now. I was trying to use dev.cur() to redraw
the graph and storing the current device id as a global variable
(rk.dist.plot.dev.id in "package:rkward" ). But once the widget is closed
using either the "Close" button or by just closing the window, I will need
this global variable to be reset (or rather removed). But I guess that is not
possible due to the generic nature of the "Close" button in
plugin/rkstandardcomponentgui.cpp? cpp codes are beyond my reach :(
> > 4. In the long run, two-dimensional distributions could be similarly
> > visialized using the "rgl" package. It is a very priliminary interface of
> > OpenGL using R.
>
> It looks like something to keep an eye on.
>
> Regards
> Thomas
Thanks to Thomas and Stefan. I will keep you posted when the new
plot_*_distribution.{xml,php} files are done.
PK
More information about the Rkward-devel
mailing list