Basemap Output is weird in Jupyter notebook

Hi, I am on Visualizing Geographic Data mission. Since I was facing problem on DQ platform (slow running, which is a ongoing problem) I started executing on my Jupyter notebook.

The output I get on Jupyter notebook is not the same as DQ output. I have attached the output for reference. I tried changing the lat and long values in basemap(llcrcrlat, etc) but I get the same output at a different position.

Here’s the code I have written:

from mpl_toolkits.basemap import Basemap as bm
import matplotlib.pyplot as plt
m = bm(projection='merc', llcrnrlat=-80, urcrnrlat=80, llcrnrlon=-180, urcrnrlon=180)
import pandas as pd
airlines = pd.read_csv('airlines.csv')
airports = pd.read_csv('airports.csv')
geo_routes = pd.read_csv('geo_routes.csv')
routes = pd.read_csv('routes.csv')
lat = airports.latitude.tolist()
long = airports.longitude.tolist()
x, y = m(lat,long)
m.drawcoastlines()
m.scatter(y, x,s=1)

Note: I am getting the correct output on DQ platform, its only on Jupyter where I get this.
Edit: Added note and a bigger image

1 Like

Hi @Sandesh,

I would like to take a look at your Jupyter Notebook file. Please send me the .ipynb file and the datasets that you have used for it.

You can do so by clicking the Upload Button in the post formatting options:
18%20PM

Also, please provide me the mission-screen link.

Thanks,
Sahil

1 Like

Hi Sahil,

I am attaching the .ipynb and the datasets. I could not upload the geo_routes.csv file as it was more than 4096KB in size. You can find it here: https://drive.google.com/open?id=1zhb9I82Z8BO7ABDSIpST9rVhgMO1Oqho

Thanks!

airlines.csv (308.9 KB) airports.csv (722.3 KB) routes.csv (2.2 MB)
Geographic plot.ipynb (711.3 KB)

Hi @Sandesh,

When I used the code you provided me, I got the following output:

The only difference I am seeing between the plot generated by Dataquest and the plot generated in my Jupyter notebook is that the marker color is black in Dataquest’s output whereas the marker color is blue in the Jupyter notebook.

download%20(1) download

Also, there is a slight border size difference which indicates that one of the below cases can be a reason for the difference:

  1. The platform has changed the default looks of the plot
  2. The platform is using an old version of basemap that had black as the default color for the marker

If you want to create a plot with black markers then set color="black" in the scatter() method:

m.scatter(y, x, s=1, color="black")

I hope this helps. Please let me know if you have any further questions I would be happy to help you.

Best,
Sahil