Reputation: 863
I created a map of some large ports. With 'x' and 'y' latitude and longitude and 'text' the port names.
x,y = map(lonA, latA)
map.scatter(x, y, s=Size, c=color, marker='o', label = 'Ports',alpha=0.65, zorder=2)
for i in range (0,n):
plt.annotate(text[i],xy=(x[i],y[i]),ha='right')
The dots I plotted (bigger dots for bigger ports) overlap with the labels. How do I plot them a little further away to increase readability?
Upvotes: 0
Views: 1741
Reputation: 863
@KiralySandor you were right, but you need to change textcoordinates to data.
for i in range (0,n):
plt.annotate(text[i],xy=(x[i],y[i]),textcoords='data',xytext=(x[i]-9000,y[i]),ha='right')
Now the names are slighlty more to the left.
Upvotes: 0
Reputation: 159
You can use the xytext
parameter to adjust the text position:
plt.annotate(text[i],xy=(x[i],y[i]),xytext=(x[i]+10,y[i]+10), ha='right')
Here I added 10 to your xy position. For more you can look up the suggestions here: https://matplotlib.org/users/annotations_intro.html
Upvotes: 1