python - Matplotlib Basemap: avoid text overlapping -
i using matplotlib basemap draw map , points labels:
map = basemap(...) x, y = map(lons, lats) label, xpt, ypt in zip(labels, x, y): plt.text(xpt + 10, ypt + 10, label, size=2)
i getting lots of overlapped labels in dense areas. there way prevent labels overlapping?
the ways can think of
- adjust distance text printing starts ( have specified 10 )
- zoom map while showing labeled points
a crude example point 2
from mpl_toolkits.basemap import basemap import matplotlib.pyplot plt m = basemap(width=120000,height=90000,projection='aeqd', resolution=none,lat_0=30.,lon_0=80.) lats=[30.0,30.1,30.2,30.0,30.1,30.2] lons=[80.0,80.1,80.2,80.3,80.4,80.5] m.bluemarble() x, y = m(lons,lats) labels=['point1','point2','point3','point4','point5','point6'] m.scatter(x,y,10,marker='o',color='k') label, xpt, ypt in zip(labels, x, y): plt.text(xpt + 10, ypt + 10, label, size=20) plt.show()
Comments
Post a Comment