Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback: Mapping in Jupyter #3

Open
iandow opened this issue Jun 28, 2017 · 7 comments
Open

Feedback: Mapping in Jupyter #3

iandow opened this issue Jun 28, 2017 · 7 comments
Labels

Comments

@iandow
Copy link
Owner

iandow commented Jun 28, 2017

No description provided.

@iandow iandow changed the title Feedback: Mapping in Jupiter Feedback: Mapping in Jupyter Jun 28, 2017
@chriddyp
Copy link

Looks great! You might want to also try out an example using scattermapbox in plotly. Here are the docs: https://plot.ly/python/scattermapbox/

@iandow
Copy link
Owner Author

iandow commented Jun 28, 2017

Scattermapbox looks great! Thanks for the fyi.

@dharasty
Copy link

THANK YOU for this excellent introduction.
Trying to recreate your examples; can you point us to "california.jpg"? Likewise for any other media assets in your demos. Maybe put a link directly in the notebook. Thanks...

@filipposebastio
Copy link

Hi there!

I was trying to use a png map of HK to pinpoint the values of airbnb apartment, but I can only get the map (HK map), not the points! Any idea why? Providing the code and the data here, thanks!


import numpy as np
import matplotlib.image as mpimg
hk_img=mpimg.imread('C:\\Users\\Filippo Sebastio\\Desktop\\hk.png')
ax = df.plot(kind="scatter", x="longitude", y="latitude", figsize=(10,7),
                       s=df.accommodates*10, label="population",
                       c=df.price, cmap=plt.get_cmap("jet"),
                       colorbar=False, vmin=0, vmax=10000,
                      )
plt.imshow(hk_img, extent=[-113.94, -114.32, 22.22, 22.37], alpha=0.2)
plt.ylabel("Latitude", fontsize=14)
plt.xlabel("Longitude", fontsize=14)

prices = df.price
tick_values = np.linspace(prices.min(), prices.max(), 11)
cbar = plt.colorbar()
cbar.ax.set_yticklabels(["$%dk"%(round(v/100)) for v in tick_values], fontsize=14)
cbar.set_label('Price', fontsize=16)

plt.legend(fontsize=16)

the data


    id   latitude   longitude property_type   price  accommodates  \

0 69074 22.283516 114.150177 Apartment 1413.0 3
1 101765 22.200224 114.134608 Townhouse 432.0 1
2 103760 22.284074 114.155696 Apartment 856.0 6
3 132773 22.288679 114.144944 Apartment 1060.0 6
4 133390 22.283435 114.155392 Apartment 942.0 2
5 163664 22.286511 114.148743 Apartment 699.0 6
6 163742 22.286944 114.148551 Apartment 777.0 6
7 174574 22.303882 114.008875 Apartment 1578.0 8
8 228510 22.309835 114.169112 Apartment 699.0 2
9 248140 22.282905 114.151365 Apartment 1091.0 2

@jm2dev
Copy link

jm2dev commented Jun 12, 2019

Regarding the missing california.png file, I just dowloaded a png map of California and save it next to my notebook.

https://www.electricitylocal.com/istate/orig/california.png

@robianmcd
Copy link

@Montz508
Copy link

Montz508 commented Feb 8, 2021

Hello!
First of all, thank you @iandow for sharing this exercise! Got really excited after finishing it.
Used the Matplot Lib, it's the one i'm most commonly used to. Also thanks to @robianmcd for sharing the California.png
Really helped me learning a bit more :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants