Hi everyone,

Sorry for the double mail, I accidentaly pushed a button that send it off
before I was finished.

I'm trying to rebuild a R example in rpy2 given in this thread in
stackoverflow:
http://stackoverflow.com/questions/3541713/how-to-plot-two-histograms-together-in-r.
The example looks like this:

    set.seed(42)
    p1 <- hist(rnorm(500,4))                     # centered at 4
    p2 <- hist(rnorm(500,6))                     # centered at 6
    plot( p1, col=rgb(0,0,1,1/4), xlim=c(0,10))  # first histogram
    plot( p2, col=rgb(1,0,0,1/4), xlim=c(0,10), add=T)  # second

This creates two histograms in one plot, with one histogram being blue, the
other being pink and the overlap being purple. You can paste and run this
in R to see the result.
So I made the following in rpy2:

    import rpy2.robjects as R
    r = R.r
    r['set.seed(42)']
    p1 = r['hist'](r['rnorm'](500,4))                     # centered at 4
    p2 = r['hist'](r['rnorm'](500,6))                     # centered at 6
    r['plot']( p1, col=r['rgb'](0,0,1,1/4),
xlim=R.vectors.IntVector([0,10]))  # first histogram
    r['plot']( p2, col=r['rgb'](1,0,0,1/4),
xlim=R.vectors.IntVector([0,10]), add=True)  # second


This gives the same overlapping histogram plot, except that histograms are
nog coloured. How can I color the histograms?

Thanks,
Niek
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to