The source of your image looks strange... Is the image really in MAC root
/tmp/ folder? Can you get it with your file browser? If so there is maybe OS
permissions issue or the file could get earased... Web2py use www-data user
(not sure on MAC)... So try to give this user access to the generated
files...

I would use : path to web2py create a folder like /output_r/ and write my
images there...

Also I would use this syntax :

src="{{=URL('static','SUBFOLDER/FILENAME.png')}}"

to get my files in view...


Richard

On Wed, Aug 24, 2011 at 8:29 AM, Richard <[email protected]> wrote:

> I am running on my Mac the following code which creates a png file in /
> tmp. Looks ok but I can't include this in my default/index view. What
> is going wrong?
>
> Create a png file in controller:
>
> def index():
>    from rpy2.robjects.packages import importr
>
>    from rpy2 import robjects
>    from rpy2.robjects import Formula
>    from rpy2.robjects.vectors import IntVector, FloatVector
>    from rpy2.robjects.lib import grid
>
>    grdevices = importr('grDevices')
>    grdevices.png(file="/tmp/rweb2output.png" , width=512, height=512)
>
>    # Plotting code
>
>    rprint     = robjects.globalenv.get("print")
>    stats     = importr('stats')
>    base     = importr('base')
>
>    lattice= importr('lattice')
>    xyplot = lattice.xyplot
>
>    datasets=importr('datasets')
>    mtcars = datasets.mtcars
>
>    formula = Formula('mpg ~ wt')
>    formula.getenvironment()['mpg'] = mtcars.rx2('mpg')
>    formula.getenvironment()['wt'] = mtcars.rx2('wt')
>
>    p=lattice.xyplot(formula)
>    rprint(p)
>
>    # close graphical device so file will be closed.
>    grdevices.dev_off()
>
>
>
>
>
> view in viewer:
>
> <p> Here is the R output via a tmp png file
> <object src="/tmp/rweb2output.png"> obj text </OBJECT>
> </p>
>
> I have tried some other options with OBJECT and DATA and IMG.
>
> Regards,
> Richard
>

Reply via email to