Skip to content

Feature request: Add ScatterGeo to draw lines on maps #300

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

Open
G0rocks opened this issue May 29, 2025 · 9 comments · May be fixed by #301
Open

Feature request: Add ScatterGeo to draw lines on maps #300

G0rocks opened this issue May 29, 2025 · 9 comments · May be fixed by #301

Comments

@G0rocks
Copy link

G0rocks commented May 29, 2025

Hello

I'm working on a project where I need to visualize some ship locations and make lines between past locations to see the traveled path and am having a confused time looking at these "straight" lines on a 2D plane so would love to be able to draw these on a globe and look at them that way.

@andrei-ng
Copy link
Collaborator

Hi @G0rocks,
Please feel free to submit a PR. It should be relatively straightforward to add.

@G0rocks
Copy link
Author

G0rocks commented May 30, 2025

Hey Andrei-ng
Yeah, I thought the same so yesterday I started on it and now I have a fork (https://github.com/G0rocks/plotly.rs) and am working on it but I am not familiar with this codebase at all and am a little confused.

Do you have any tips for me?

I started out by copying everything Mapbox and renaming it to geo and then my plan was to change those things actually do the geo plotting but I'm a little lost.
Note I'm not an expert in programming or rust I just kind of dabble.

Thanks :)

@G0rocks
Copy link
Author

G0rocks commented May 30, 2025

Also writing here so I don't forget, this needs to go in the changelog somehow when it is ready

@G0rocks
Copy link
Author

G0rocks commented May 30, 2025

I'm stuck where I'm always getting the same projection and not sure how to change it. Any help would be well appreciated.

@andrei-ng
Copy link
Collaborator

andrei-ng commented May 31, 2025

Hi, @G0rocks , I am currently traveling. I will have a look tomorrow at your fork when I am back

@andrei-ng
Copy link
Collaborator

@G0rocks, you've started on the right path. Indeed, this specific type of traces need a new type of Layout options which are also not available in Plotly.rs. I think when you are talking about projections, you mean to be able to do something like this, right?

import plotly.express as px
df = px.data.gapminder().query("year == 2007")
fig = px.scatter_geo(df, locations="iso_alpha",
                     color="continent", # which column to use to set the color of markers
                     hover_name="country", # column added to hover information
                     size="pop", # size of markers
                     projection="natural earth")
fig.show()

https://plotly.com/python/scatter-plots-on-maps/

For that, I think I will need to add the Layout.geo API similar to Python, https://plotly.com/python/reference/layout/geo/

I can look into that at the end of the week, but if you want to have a go, you can try on your own until then.

@andrei-ng andrei-ng linked a pull request Jun 2, 2025 that will close this issue
@andrei-ng
Copy link
Collaborator

andrei-ng commented Jun 2, 2025

I've just opened a Draft PR based on your work in your fork.
EDIT: @G0rocks can you change your fork such that you allow maintainers from plotly.rs to push to your fork?

@G0rocks
Copy link
Author

G0rocks commented Jun 2, 2025

Thanks @andrei-ng

I am talking about doing something like those but what I would most like to have is something like this one
Image
https://plotly.com/javascript/lines-on-maps/

Though what I have now is good enough for my purposes
Image
You can tell it's already helpful since I can see that I'm out of bounds :)

Thanks for opening a draft PR, I'll see if I can change it so maintainers from plotly.rs can push to the fork.
EDIT: I am in a little bit of a hurry and couldn't find it out quickly in the github docs so I just gave you collaboration access. Hope it's good enough for now!

@andrei-ng
Copy link
Collaborator

Thanks for the examples. Now I understand what you are after. I will look into it, it is a matter of adding support for Layout.Geo.

I have access to your fork and can push changes now. Thank you!

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

Successfully merging a pull request may close this issue.

2 participants