Thanks to @JoeKington here and @EdSmith in How to Overlay Numbers in matplotlib , I was able to figure out how to achieve what I wanted: to reuse the base map objects and walk them around.
I did it like this:
- Created
base_map.py , which has two functions: plot() , which create a map object and draw some properties and others, set_a_map() , which create an empty map object. In other modules, I added a map=None property to the chart functions, and in each function I added:
if not map: map = base_map.set_a_map()
So, if the map object is not passed to another function, the function will create a new map object.
In my chart functions, instead of using plt.imshow(...) , for example, I use map.imshow(...) . Thus, my data will be displayed on the map.
Thanks for your patience and really useful comments!
source share