Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw an arrow on an Basemap object using matplotlib?

I have been trying to draw arrows on a Basemap object for quite a while already. I found help for drawing lines on the map, but it seems that the arrowhead just does not want to appear.

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

map = Basemap(projection='merc', lat_0 = 57, lon_0 = -135,
resolution = 'i', area_thresh = 0.1,
llcrnrlon=-136.25, llcrnrlat=56.0,
urcrnrlon=-134.25, urcrnrlat=58)

map.drawcoastlines()
map.drawcountries()
map.drawmapboundary()

lon = -135.3318
lat = 57.0799
x,y = map(lon, lat)
x2, y2 = map(lon+0.5,lat+0.5)

plt.arrow(x,y,x2-x,y2-y,fc="k", ec="k", linewidth = 4, head_width=10, head_length=10)
plt.show()

As a result I only get: http://i.imgur.com/tB6wi2J.png You can see a little bit of a head, but almost nothing. Am I just to stupid to get the arguments right? I have been fiddling around for quite a while...

EDIT: Yes I was just to stupid to get the arguments right. I put 10000 for head width and length and an arrow was visible.. I think because of basemap it calculates in metres and that threw me off.

like image 357
Ansurreccion Avatar asked Oct 20 '22 19:10

Ansurreccion


1 Answers

I just did not put the arguments right. On the scale used it hat to be at least 10000 head_width and head_length

like image 173
Ansurreccion Avatar answered Oct 22 '22 08:10

Ansurreccion