Colors in plots

7 views
Skip to first unread message

Joel

unread,
Sep 27, 2010, 4:42:24 AM9/27/10
to r-node-users
Hope you dont think Im annoying with alot of questions.

But I want to know if you can add colors to your plots in R-node been
trying with just a really simple plot but it only prints the color
blue on all.
Been trying:
plot(iris$Sepal.Length, iris$Petal.Length, col=unclass(Species))
plot(iris$Sepal.Length, iris$Petal.Length,
col=c("red","blue","green"))
plot(iris$Sepal.Length, iris$Petal.Length, col=c(1,2,3))

And they all work if used directly in R but not in R-node.

Is there any R-node specific command that I need to use or is it just
not implemented?
If not are there any plans to implement color settings on the plots?

Joel

unread,
Sep 27, 2010, 4:50:48 AM9/27/10
to r-node-users
Got one more Q what kind of plots do R-node handle, as Im trying to
get a barplot but I dont get any plot back but all the commands work
if I look at the logs.

Joel

unread,
Sep 27, 2010, 5:03:47 AM9/27/10
to r-node-users
Found a work around to the first problem by not letting it plot
"inside" R-node but rather give me back a pdf file that i can view
then ill get it in the colors I want. Still would be nice to have the
colors in the little window inside R-node

On 27 Sep, 10:42, Joel <jolle...@hotmail.com> wrote:

Joel

unread,
Sep 27, 2010, 5:10:23 AM9/27/10
to r-node-users
Found that if I use png it works inside the little window aswell... :P
always good when you can answer yout own Qs

Jamie Love

unread,
Sep 28, 2010, 4:04:49 AM9/28/10
to r-node...@googlegroups.com
Hi Joel,

Initially when I started developing R, I was keen to re-implement the basic plot functions and all their options in javascript with protovis, a graphing library (so all plots could be generated as SVG).  In the end I didn't get very far with this approach - primarily because in the end I felt the library here: http://cran.r-project.org/web/packages/webvis/index.html approached it better.

Anyway, to use the R graphing functions, in the 'graphs' menu uncheck the "use SVG when available" option and you should find all the graphing works.
--
Jamie Love
Looking for custom software development? Contact us at www.nsquaredsoftware.com.

Jamie Love

unread,
Sep 28, 2010, 4:05:42 AM9/28/10
to r-node...@googlegroups.com
They should all be supported if you uncheck the "use SVG when available" option -    SVG graphs are very limited at the moment.

but if one doesn't, let me know.

Ta 
Jamie

Joel

unread,
Sep 28, 2010, 4:06:37 AM9/28/10
to r-node-users
Thx for the help

Joel

unread,
Sep 28, 2010, 4:14:58 AM9/28/10
to r-node-users
Im sad to say that barplot still dossent work with the SVG opt off
dossent seem like r-node know that barplot is a graphical mechanism.

If there is any special info I can post to help you in your work, just
let me know.
//Joel

Jamie Love

unread,
Sep 28, 2010, 4:22:02 AM9/28/10
to r-node...@googlegroups.com
What R commands are you using?

Joel

unread,
Sep 28, 2010, 4:25:09 AM9/28/10
to r-node-users
Right now just to try it I used
barplot(c(1,2,3))

Jamie Love

unread,
Sep 28, 2010, 4:28:35 AM9/28/10
to r-node...@googlegroups.com
Hiya,

I've made a small change that will allow bar plots to show as graphs in your browser. Update from the git repository.

Jamie

Joel

unread,
Sep 28, 2010, 4:40:08 AM9/28/10
to r-node-users
Thx, but guessing the same problem will occur with every new kind of
plot I'll try or was this a special case?

I can see great potential in this project thats why Im so curious :D

//Joel

Jamie Love

unread,
Sep 28, 2010, 4:52:48 AM9/28/10
to r-node...@googlegroups.com
You're right

Currently I have a hard coded list:

'boxplot', 'title', 'plot', 'pairs', 'coplot', 'qqnorm', 'qqline', 
        'qqplot', 'dotchart', 'image', 'contour', 'persp', 'points', 'lines', 'barplot',
        'text', 'abline', 'polygon', 'legend', 'title', 'axis', 'locator', 'identify' 


- there are two things that would help:

1/ allow a prefix to commands to indicate it's graphical (allowing r-node to deal with it as a graphical command)
2/ allow the above list to be edited by users/admins in the UI.

for now, you can add to the list on line 128 of the file '500-r.js'.  After you add to the list, just restart r-node.

Regards,
Jamie

Joel

unread,
Sep 28, 2010, 5:03:54 AM9/28/10
to r-node-users
Thx

Y a more dynamic approach would be prefered even if it means some r-
node specific commands.

The second approach could also work if you can implement the admin/
user group, would also be cool if the admin could block specific
commands for example if you have RMySQL on your Rserver but don't want
the users to be able to use dose options. (only the admin should be
able to read new data into R from the database that then can be used
by the users).

Now Im just thinking out load but cant you somehow check if a dev
command is called in R as that usally means an graphical thing is
coming.

Jamie Love

unread,
Sep 28, 2010, 3:29:36 PM9/28/10
to r-node...@googlegroups.com
Hiya,

Blocking commands is something that can be done, to some extent - e.g. try running q() in r-node and you'll see it is restricted. The R-node server stops it running.
The difficulty is in making sure that it is never called.   There are a variety of ways users can still call q(), so the restriction is good to stop trusted users, but won't stop malicious users.  

Comprehensive security is very hard - languages such as Java and javascript have had it built in from the start, and so with them it's possible. R is exceedingly permissive as it assumes anyone that runs R is essentially a superuser. This makes restricting commands difficult.   The approach I've taken for this is to use a chroot jail, but that is fairly heavy handed.

I'll look again at using 'dev' to identify graphics commands.

Jamie

Shane Conway

unread,
Sep 28, 2010, 3:52:11 PM9/28/10
to r-node...@googlegroups.com
Sorry...I'm slow to respond on this, but I wanted to mention:

As the author of the webvis package, I'm also very happy to have
feedback and see where I can help to improve the R-node plots. I have
plans for further extensions to it (although time hasn't been on my
side recently) and have another collaborator to help. See more here:
http://code.google.com/p/rwebvis/

Joel

unread,
Sep 29, 2010, 3:06:02 AM9/29/10
to r-node-users
Will see if anything about the plots do come up, but I most say Im not
so sure what webvis is doing in R-node and what R-node is doing it
self :P so hard to separate for me... Im guessing its the drawing of
the plot that webvis is doing...

//Joel (sry for bad english in this post)

On 28 Sep, 21:52, Shane Conway <shane.con...@gmail.com> wrote:
> Sorry...I'm slow to respond on this, but I wanted to mention:
>
> As the author of the webvis package, I'm also very happy to have
> feedback and see where I can help to improve the R-node plots.  I have
> plans for further extensions to it (although time hasn't been on my
> side recently) and have another collaborator to help.  See more here:http://code.google.com/p/rwebvis/
>
> On Tue, Sep 28, 2010 at 4:04 AM, Jamie Love <drjl...@gmail.com> wrote:
> > Hi Joel,
> > Initially when I started developing R, I was keen to re-implement the basic
> > plot functions and all their options in javascript with protovis, a graphing
> > library (so all plots could be generated as SVG).  In the end I didn't get
> > very far with this approach - primarily because in the end I felt the
> > library
> > here: http://cran.r-project.org/web/packages/webvis/index.html approached it
> > better.
> > Anyway, to use the R graphing functions, in the 'graphs' menu uncheck the
> > "use SVG when available" option and you should find all the graphing works.
>

Jamie Love

unread,
Sep 29, 2010, 3:15:48 AM9/29/10
to r-node...@googlegroups.com
Basically in R-Node I just look for calls to rwebvis (e.g. plot.rwebvis(...), and capture them, extracting the code and running it in R-Node. It basically means that results of calls to rwebvis functions appear nicely to people.

I don't automatically at this stage use rwebvis (I didn't think it was completed enough - though I may be wrong).

Jamie

Joel

unread,
Sep 29, 2010, 3:20:04 AM9/29/10
to r-node-users
So if im correct the user most use webvis for R-node to use webvis.

//Joel
Reply all
Reply to author
Forward
0 new messages