Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webagg changes #1878

Merged
merged 4 commits into from Apr 12, 2013
Merged

Webagg changes #1878

merged 4 commits into from Apr 12, 2013

Conversation

pelson
Copy link
Member

@pelson pelson commented Apr 2, 2013

Some refactoring work on the WebAgg backend.

Key features:

  • you can now run the backend with a url prefix (i.e. it is now possible to run the service under 127.0.0.1/mpl/*, if you so desired)
  • objectified the JS figure (and associated web socket) so that more than one figure can exist on the same page
  • there is an "all figures" landing page which handles keyboard & mouse focus appropriately
  • the creation of the appropriate HTML elements is now easier due to the mpl_interface.js factory functions

I've been testing this out with the following code:

import matplotlib
matplotlib.use('webagg')

import matplotlib.pyplot as plt

plt.figure()
plt.plot(range(10))

plt.figure('wibble')
plt.bar(range(10), range(10))


plt.show()

I still have some other changes I'd like to make to the WebAgg architecture, but I think this is a reasonable first step which adds some nice, self contained, functionality.

@pelson
Copy link
Member Author

pelson commented Apr 2, 2013

Note: one of the changes I was referring to was to JSLint the javascript - I'd be happy to do that here before anybody sets their eyes on my (probably poor) javascript. Shout if you'd like that to happen now, otherwise, I'll probably defer the linting to my next PR ;-)

def __init__(self, url_prefix=''):
if url_prefix:
assert url_prefix[0] == '/' and url_prefix[-1] != '/', \
'url_prefix must start with a "/" and not end with one.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we instead just add the prefix / if it's not there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are fine, it's something most people will never use (I don't propose making in an RcParam) - its for follow on applications (which I plan to look at in the next couple of weeks) for which I will want to implement a namespace. The one thing in favour of this approach is that there is no ambiguity - if you get it wrong then you will get a decent message about it, but I can also see the other side of the argument too (if you can check that something is wrong, you can fix it programatically for the user...)

@mdboom
Copy link
Member

mdboom commented Apr 2, 2013

This is great. I think the objectification work you've done to allow multiple figures on the same page will come in very handy when this gets integrated with IPython notebook. (I hope to hash out a plan for that at Scipy if I can get all the experts in the room together...)

I am getting this message when I run this (haven't really looked into why):

ERROR:root:Uncaught exception GET /favicon.ico (127.0.0.1)
HTTPRequest(protocol='http', host='127.0.0.1:8988', method='GET', uri='/favicon.ico', version='HTTP/1.1', remote_ip='127.0.0.1', body='', headers={'Accept-Charset': 'UTF-8,*;q=0.5', 'Connection': 'keep-alive', 'Accept-Language': 'en-US,en;q=0.8', 'Accept-Encoding': 'gzip,deflate,sdch', 'Host': '127.0.0.1:8988', 'Accept': '*/*', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31'})
Traceback (most recent call last):
  File "/home/mdboom/python/lib/python2.7/site-packages/tornado-2.4.1-py2.7.egg/tornado/web.py", line 1042, in _execute
    getattr(self, self.request.method.lower())(*args, **kwargs)
  File "/home/mdboom/python/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/backends/backend_webagg.py", line 379, in get
    with open(os.path.join(self._mpl_dirs['images'],
AttributeError: 'FavIcon' object has no attribute '_mpl_dirs'

@pelson
Copy link
Member Author

pelson commented Apr 2, 2013

Fixed the favicon directory problem in 786a6b4.

@pelson
Copy link
Member Author

pelson commented Apr 12, 2013

@mdboom - any actions on this? I'm keen to reduce my number of PRs 😄

@mdboom
Copy link
Member

mdboom commented Apr 12, 2013

Now that the favicon thing is fixed, I think this is good to go.

mdboom added a commit that referenced this pull request Apr 12, 2013
@mdboom mdboom merged commit 9e477b3 into matplotlib:master Apr 12, 2013
@pelson
Copy link
Member Author

pelson commented Apr 12, 2013

Cool. Thanks @mdboom. I'm going to start up a conversation on the ipython-dev mailing list in the next week or so to start thinking about notebook magic. I'd like to be able to use it in a talk at SciPy 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants