I'm using the Basemap
object from basemap
module in the matplotlib toolkit (mpl_toolkits.basemap.Basemap
). In basemap
's __init__.py
file (i.e. the mpl_toolkits.basemap.__init__
module), a method drawparallels
is defined which draws latitudes on the map. I aim to duplicate that method to make a new method called drawmlat
, making some adjustments in order to plot magnetic latitudes instead of geographic latitudes.
Ideally, I want the new drawmlat
to be equivalent to the original drawparallel
(a bound method of the instances of Basemap that I can call with using BasemapInstance.drawmlats()
), and I do not want to modify the original file. How would I accomplish this?
I have tried variations of the "recipe" MyObj.method = MethodType(new_method, None, MyObj)
, but without placing anything in the original source file, the new method does not have access to globals etc. from the Basemap module (e.g. defined in its __init__.py
).
If it seems I have misunderstood something, I probably have - I am more or less completely new to object-oriented programming.