I had a look at this, and hist did some very weird things for me in
rpy2, plotted a lot of numbers over the top of the histogram. I had
better luck with histogram from the package lattice.
 
I was wondering, do you want a histogram of the values in d that fall
between 200 and 2000? If so, you probably should subset the data first.
If you do want to just show the part of the histogram within a
particular range, I think something like this would work:


from rpy2 import robjects
from rpy2.robjects.lib import grid
from rpy2.robjects.packages import importr

# The R 'print' function
rprint = robjects.globalenv.get("print")
grdevices = importr('grDevices')
base = importr('base')
lattice = importr('lattice')
r = robjects.r
V1 = r.rnorm(1000,3700,2500)

# the full histogram
p = lattice.histogram(V1,breaks=50)
rprint(p)

# just the bit you want, ie zoom in on a section
p = lattice.histogram(V1,breaks=50,xlim=robjects.IntVector([200,7200]))
rprint(p)

________________________________

        From: Matthew MacManes [mailto:macma...@gmail.com] 
        Sent: Thursday, 4 November 2010 2:37 AM
        To: rpy-list@lists.sourceforge.net
        Subject: [Rpy] specify xlim for hist()
        
        
        Hi All,  
        
        
        Can anybody tell me how I can set xlim for a histogram, the
catch is that the xlim I want does not cover the entire range of x
values...
        
        
        The snippet of R code I am trying to recreate in rpy2:
                <code>hist(V1,breaks=100, xlim=c(200,7200))</code>
                
        
        With rpy2, I can do something like:
        <code>graphics.hist(d, r_base.seq(200, 7200, 100), col =
"lightblue", main = "contig length", xlab = "length (bp)</code>
        
        
        but I get the error:
        some 'x' not counted; maybe 'breaks' do not span range of 'x'
        and the plot is not created. i'm fine with some of my
observations not being counted, this is in fact what I am hoping for... 
        
        
        
        
        Of course, ive tried:
                <code>graphics.hist(d, breaks = 100, xlim = c(200,2000),
col = "lightblue", main = "contig length", xlab = "length (bp)")</code>
        
        
        but this returns the error:
        TypeError: 'DataFrame' object is not callable
        
        
        This seems like such a simple problem, but I cant seems to
figure it out. 
        Thanks, Matt
        
        
        


+----------------------------------------------------------------+
Think B4U Print
1 ream of paper = 6% of a tree and 5.4kg CO2 in the atmosphere
3 sheets of A4 paper = 1 litre of water
+----------------------------------------------------------------+


------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to