Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

draw a marker in basemap python

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

# 1. get data 
lon = [-122.2416355, -122.2977475, -121.204408, -118.3272612, -119.0194639]
lat = [37.7652076, 37.88687, 40.2362738, 33.34221, 35.3738712]
crowd = [8.0, 500.0, 4.0, 44.0, 119.0]

# 2. draw map 

map = Basemap(projection='lcc', resolution='h', 
            lat_0=37.5, lon_0=-119,
            width=1E6, height=1.2E6) 

map.drawcoastlines()
map.drawcountries()
map.drawstates()
map.fillcontinents()
map.drawmapboundary()
x,y = map(lon, lat)   # convert (long-lat) degrees to map coords

for x1, y1, c in zip(x, y, crowd):
    # markersize is scale down by /10
    # need alpha<1 to get some transparency
    # red color is more appropriate
    map.plot(x1, y1, 'ro', markersize=c/10., alpha=0.4)

plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: western school district 
Python :: reassign variable python 
Python :: cv2 put font on center 
Python :: how to install pandas in python by git 
Python :: forward fill pandas ffill 
Python :: oauthlib python error 
Python :: The module in NAME could not be imported: django.contrib.user_auth.password_validation.UserAttributeSimilarityValidator. Check your AUTH_PASSWORD_VALI 
Python :: concat dataset 
Python :: rotate an image python keras 
Python :: django template child data in nested loop 
Python :: hidden semi markov model python from scratch 
Python :: how to count to 1billion in python 
Python :: pyqt message box set detailed text 
Python :: print("python is good") 
Python :: how to make a list with the same string in python 
Python :: dont print pip jupyter 
Python :: how to print out voice level in python 
Python :: Regular Expressions In Practical NLP example 
Python :: Pandas dataframe with MultiIndex: check if string is contained in index level 
Python :: paraphrase tool free online 
Python :: multiKey dict error 
Python :: Compute p-value 
Python :: time for range in python 
Python :: pandas to_csv adds unnamed column 
Python :: <h1</h1 
Python :: python raccourci mettre paragraphe commentaire 
Python :: python concurrent.futures.ProcessPoolExecutor multiple arguments 
Python :: TypeError: strptime() argument 1 must be str, not list 
Python :: pyqt set widget size 
Python :: some problem occurred shows payubiz 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =