Plotting curved line in Python Basemap

陌路散爱 提交于 2019-12-12 09:43:03

问题


I would like to plot curved/arced lines on a Basemap map. I can plot a straight line using map.plot(x,y,..), but how do I make it curved/have arrows?

In matplotlib, this can be done using annotate(..), but Basemap doesn't have this method.

Any ideas?


回答1:


This is a very old question, but I thought it might be good to answer anyway. When you said curved lines, I assumed you meant drawing a great circle. There is an example of doing exactly that in the basemap documentation, which I have modified to make a little more easy to modify yourself:

from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt

m = Basemap(projection='cyl')

p0_ll =  -73.98, 40.78
p1_ll = 0.08, 51.53

m.drawgreatcircle(p0_ll[0], p0_ll[1], p1_ll[0], p1_ll[1], 
                  linewidth=2, color='b')
m.drawcoastlines()
m.fillcontinents()

plt.show()

Note that the great circle method cannot handle the crossing of the edges of the map (as mentioned in the documentation), which, although clearly documented, is a pretty major flaw IMHO.

Hope that helps somebody,



来源:https://stackoverflow.com/questions/4451451/plotting-curved-line-in-python-basemap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!