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

Integrate into subplot #16

Closed
omerfarukeker opened this issue Sep 12, 2018 · 3 comments
Closed

Integrate into subplot #16

omerfarukeker opened this issue Sep 12, 2018 · 3 comments

Comments

@omerfarukeker
Copy link

Hi tcassou,

Thank you very much for the work!

I am new to Python. I invoke mplt.scatter function in a for loop, each time inputting with the corresponding row of my dataframe. 2 problems I encounter so far:

  1. When I pass the dataframe's ith row in the for loop mplt.scatter(df_geo['latitude'][i],df_geo['longitude'][i]) it throws the following error "numpy.float64' object has no attribute 'index". I wanted to put ith dot on the map within the loop.

  2. In the for loop, each time it creates a figure, how can I put it one of my subplots and update the map in the for loop.

Cheers,

@tcassou
Copy link
Owner

tcassou commented Sep 13, 2018

Hi @slayomer, thanks for asking!

  1. The scatter method (as well as other plot methods) expect pandas.Series objects as arguments for both latitudes and longitudes (you can see this in the docstring). When accessing the ith element with df_geo['latitude'][i], what you get is a float instead, which causes the program to fail.
    So in your case if you need to plot only 1 point on the map, you could for example use this instead: df_geo['latitude'][i:i+1], which is the sub series from ith (included) to (i+1)th (excluded) element. I would on top suggest to explicitly use the iloc method (so df_geo['latitude'].iloc[i:i+1]) to avoid confusion.
    On my end I'll think of ways to validate the input and print out more explicit error messages!

  2. In the current setup the figure is defined inside plotting methods, and the show method is called, causing the plot to be rendered.
    If you have suggestion on how to add support for subplots while keeping compatibility with current use cases, happy to hear them!

@omerfarukeker
Copy link
Author

Hi @tcassou thanks for your swift response, it worked well.

Also managed to solve the other issues which are:

  1. Commented out the line 79: plt.figure(figsize=(10, 10)) as it creates new figure each time scatter function of the mapsplot.py is invoked.
  2. Also zoom of the map wasn't working properly in the for loop (it was too wide), I changed it to 20 which worked well.

Thanks again creating such nice library for google maps plotting.

Cheers,
Omer

@tcassou
Copy link
Owner

tcassou commented Sep 20, 2018

Hi @slayomer
Good to hear it worked out - and thanks for the nice words!
About subplots if you think of an elegant way of enabling this option through the package while keeping compatibility with the current API, feel free to send a pull request.

I'll close this issue for now, don't hesitate to reopen it if needed,
Thomas

@tcassou tcassou closed this as completed Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants