Drawing ellipses on matplotlib basemap projections-How to extend the basemap class
Question: I am new to python and matplotlib (and stackoverflow). Can you please tell me
how do I extend my basemap class with this ellipse function? The original post
"Drawing ellipses on matplotlib basemap projections" from regeirk is exact
what I need but I do not know how to extend the class.

Here is the code from regeirk: [Drawing ellipses on matplotlib basemap
projections](http://stackoverflow.com/questions/8161144/drawing-ellipses-on-
matplotlib-basemap-projections)

I do not know how to implement it extending the basemap class. I have never
done this before.

I hope I provided all the info.

Thanks.


Answer: With python, you can extend a class without needing to modify the Basemap
sourcecode itself. Simply importing the following code (maybe by just having
it inline in your script) will modify the functionality of a class (In this
case, we may as well modify the Basemap class):

    
    
    from mpl_toolkits.basemap import Basemap
    
    def ellipse(self, x0, y0, a, b, n, ax=None, **kwargs):
        print 'Hello world!'
    
    Basemap.ellipse = ellipse
    

Now, when you create a Basemap instance it will have the appropriate "ellipse"
method.

See also <http://dietbuddha.blogspot.co.uk/2012/12/python-metaprogramming-
dynamically.html>

