Can't plot in codenode

3 views
Skip to first unread message

Eric

unread,
Sep 9, 2010, 4:16:45 PM9/9/10
to codenode-devel
Hi there,

I have installed a codenode server both locally on my desktop and also
publically on my server space. But for whatever reason I can't get the
plotting to work. I import numpy and matplotlib, create a simple array
and then try to plot it, but no luck. I have also played around
extensively with the various backends which come with matplotlib, but
it simply won't plot. Can anybody give me a hint as to what I am doing
wrong ?

Thanks,
Eric

James Casbon

unread,
Sep 10, 2010, 6:25:23 AM9/10/10
to codenod...@googlegroups.com

Don't import matplotlib directly, as there is a special function
called show() which handles the plot rendering.

Try creating a new notebook and running

plot([1,2,1])
show()


James

Eric

unread,
Sep 10, 2010, 4:37:06 PM9/10/10
to codenode-devel
Thanks for the answer to far, but I tried what you suggested and it
still does not work. I would provide a screenshot, but don't know how.
Basically, when I execute show() the output line has one of these
broken image link icons popping up... looks almost like an orphan link
reference to an image which is not there (or was not generated by the
backend. Any other suggestions as to what might have gone wrong?

Thanks,
Eric


On Sep 10, 11:25 am, James Casbon <cas...@gmail.com> wrote:

Eric

unread,
Sep 10, 2010, 5:07:09 PM9/10/10
to codenode-devel
Maybe I should mention that I am always installing codenode on the
latest ubuntu 10.04 lucid where versions of matplotlib and numpy are
already installed. I also tried running the codenode server on another
machine and here after the show() command there is no orphan link, but
instead the output window just remains empty... I don't know if this
matters, but in the command line prompt where i have launched
manually, when i try to use show() in the frontend, behind the scenes
on the command line it almost looks as if the rendered graph is
outputed as a file to the command line (lots of symbols etc - looks
very machine-cody to me, if you excuse my layman way of expressing
myself) - any suggestions?

Thanks,
Eric

Eric

unread,
Sep 10, 2010, 6:18:23 PM9/10/10
to codenode-devel
Okay - I found at least the source of the problem... the broken orphan
link which shows up in the output window after I typed show() points
to localhost/data/plot_images, BUT...
for some strange reason the graphs are only accessible from localhost/
data directly, without the plot_images path in between. What happened
here?

Thanks,
Eric

Bartosz Telenczuk

unread,
Sep 12, 2010, 6:53:49 PM9/12/10
to codenod...@googlegroups.com
Hi Eric,

I can reproduce the error. The problem is with the twisted web server which serves data/plot_images under localhost/data (the plot_images is dropped). There is an easy way to fix it by changing the configuration of the web server (in service.py), but I am not sure if this is really the right solution (it exposes whole user's project directory to the web). Lets better ask core developers!

For know, you can find my patch in the attachement.

Cheers,

Bartek

0001-data-points-to-the-home-path-not-to-the-images-direc.patch

James Casbon

unread,
Sep 13, 2010, 4:07:06 AM9/13/10
to codenod...@googlegroups.com
OK, this is a screwup.

I remember changing this not to use files at all but put base64
encoded image into the JSON cell - clearly that never made it in, but
is a better approach IMO.

I'll look at applying the patch when I get a minute.

On 12 September 2010 23:53, Bartosz Telenczuk

>> --
>> http://groups.google.com/group/codenode-devel?hl=en
>> http://codenode.org
>
>
> --
> http://groups.google.com/group/codenode-devel?hl=en
> http://codenode.org
>

Bartosz Telenczuk

unread,
Sep 13, 2010, 5:04:14 AM9/13/10
to codenod...@googlegroups.com
>
> I remember changing this not to use files at all but put base64
> encoded image into the JSON cell - clearly that never made it in, but
> is a better approach IMO.

As far as I understand this is exactly how it works. Python intepreter
puts the image into the json and when backend receives it it is saved
a file.

I am still thinking about using canvas backend to render figures,
which would solve the problem. It seems that I won't be easy, because
it needs another communication channel with matplotlib server.

Cheers,

Bartosz

James Casbon

unread,
Sep 13, 2010, 5:19:31 AM9/13/10
to codenod...@googlegroups.com
On 13 September 2010 10:04, Bartosz Telenczuk

<bartosz....@gmail.com> wrote:
>>
>> I remember changing this not to use files at all but put base64
>> encoded image into the JSON cell - clearly that never made it in, but
>> is a better approach IMO.
>
> As far as I understand this is exactly how it works. Python intepreter puts
> the image into the json and when backend receives it it is saved a file.
>
> I am still thinking about using canvas backend to render figures, which
> would solve the problem. It seems that I won't be easy, because it needs
> another communication channel with matplotlib server.

No, if you encode the image as base64 it is saved as part of the JSON
in the database. No file is needed.

At the moment it is pickled and then saved to disk.

Reply all
Reply to author
Forward
0 new messages