Alexis Perez
Alexis Perez

Reputation: 201

Lat/Long data point not showing up on Basemap plot

I have lat/long data points I am trying to plot on a map using Matplotlib's Basemap. Several points are not showing up and I am not sure why.

I tried to simplify my code as much as possible in order to understand where the issue is occurring.

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

lat = [39.62, 38.97, 40.75, 41.19] 
lon = [-121.76, -78.38, -87.66, -104.91]

fig = plt.figure(figsize=(18,18))
m=Basemap(projection='cea')
m.drawcoastlines()
m.fillcontinents()
m.drawmapboundary()


m.scatter(lat,lon,zorder=10,latlon=True)

map plot

I attached the image of the result. I applied the solutions to two other questions:

  1. Issue was zorder, so I set the zorder =10
    `map.scatter` on basemap not displaying markers
  2. Issue was latlon=True so I set latlon = True.
    scatter plot data does not appear on continents in 'hammer' basemap

I also tried

x,y = m(lat,lon)

m.scatter(x,y,zorder=10)

yet nothing showed up. I couldn't find any other reasons why datapoints won't show up. I confirmed in Google Maps that these are valid lat/lon coordinates that should show up in USA.

What am I missing?

Upvotes: 3

Views: 1791

Answers (1)

Alexis Perez
Alexis Perez

Reputation: 201

Solution: Plot as Lon, lat not lat, lon.

This worked.

Upvotes: 3

Related Questions