Issue
The following code is an attempt to put points on a map via mplleaflet in a Jupyter notebook. It works for the first 3 points but not when including the 4th. It must be something other than this point - I can plot the 4th and 5th together for example. I want to be able to plot all the points including after the pound signs. Any ideas what's going wrong?
%matplotlib inline
import mplleaflet
import matplotlib.pyplot as plt
lats = [54.3256, 53.2692, 53.8242, 53.2178] #, 51.9978, 52.42, 53.1658, 54.292, 52.127, 51.505, 51.478, 51.35]
lons = [2.9356, 3.6278, 2.9453, 3.2203] #, 3.275, -1.83, 0.5239, -1.535, 0.956, -1.993, -0.461, 1.3667]
plt.hold(True)
plt.plot(lons, lats, 'rs')
mplleaflet.display()
EDIT: I've given up trying to use plt.scatter as this does not seem to work at all. EDIT 2: seems I just needed to get rid of the 'mplleaflet.display()' suggested in the original code I was trying to make work. Hold is now depreciated however - see alternative below.
Solution
Try this:
import mplleaflet
import matplotlib.pyplot as plt
lats = [54.3256, 53.2692, 53.8242, 53.2178]
lons = [2.9356, 3.6278, 2.9453, 3.2203]
fig = plt.figure() #This is missing in your code.
plt.plot(lons, lats, 'r.')
#And after this call the funtion:
mplleaflet.display(fig=fig)
#It will display the matplotlib object created by plot function
Answered By - chetan_surwade
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.