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

[Feature Request] Support line styles in Scattermapbox #6791

Open
Worschi opened this issue Nov 22, 2023 · 9 comments
Open

[Feature Request] Support line styles in Scattermapbox #6791

Worschi opened this issue Nov 22, 2023 · 9 comments

Comments

@Worschi
Copy link

Worschi commented Nov 22, 2023

It would be nice to plot lines of different styles, e.g. dashed, dotted, etc. to a Scattermapbox layer. The lack for this feature has been noted here How do I change the line style to dash in a scattermapbox plot?, and here How to change line shape in mapbox maps?

Currently (Plotly 5.18), the only supported line attributes are "color" and "width" . However, distinguishing lines by color is not sufficient for monochrome styled figures. In addition, certain line styles are frequently expected:

  • minor roads = dashed line
  • under construction = dotted line
@Coding-with-Adam Coding-with-Adam transferred this issue from plotly/plotly.py Nov 22, 2023
@Coding-with-Adam Coding-with-Adam changed the title Support line styles in Scattermapbox [Feature Request] Support line styles in Scattermapbox Nov 22, 2023
@Coding-with-Adam
Copy link
Contributor

Coding-with-Adam commented Nov 22, 2023

Good idea, @Worschi.
Would you be interested in seeing if you can find this functionality in Mapbox itself and figure out how the API compares with what we have for line dash and scatter traces?

@Worschi
Copy link
Author

Worschi commented Nov 24, 2023

Hello @Coding-with-Adam, thanks for noticing! I'd probably be able to do some more research and post my findings here. I already came accross a working code snippet for "line-dasharray" styled lines in the mapbox-gl.js class.

Have a look at this minimal jsfiddle example. It uses a "line-dasharray" in the mapbox-gl.js to plot dashed lines. There may be better ways though since my initial reseach was not thorough.

Would you be so nice as to point me in the right direction for plotly API to mabox API mapping?

@archmoj
Copy link
Contributor

archmoj commented Nov 24, 2023

Please see this mock: https://raw.githubusercontent.com/plotly/plotly.js/master/test/image/mocks/mapbox_geojson-attributes.json which renders as https://raw.githubusercontent.com/plotly/plotly.js/master/test/image/baselines/mapbox_geojson-attributes.png

@Worschi
Copy link
Author

Worschi commented Nov 26, 2023

Nice! Thanks, @archmoj. I'll try this out beginning of the week and let you know if it worked for my use case. I'll keep you posted and close this issue in case it did.

@Worschi
Copy link
Author

Worschi commented Nov 29, 2023

Hello, the dashed line style does indeed work in geojson layers. I set up a minimal working example to demonstrate: dashed line in mapbox layer example

I am confident, that I can tweak my code to use geojson lines instead of Scattermapbox traces. I'll go ahead an close this issue now. Although I wonder if the documentation should improve in this regard? Several people looked for this on the internet and could not find solutions. Anyhow, thanks again @archmoj for pointing this out! I'd not have found this in the docs quickly.

@Worschi Worschi closed this as completed Nov 29, 2023
@alexcjohnson
Copy link
Contributor

Thanks @Worschi! Good to know that this can be done with a geojson layer. But I'd like to keep this issue open until we investigate adding it to scattermapbox, that will still be more useful if we can get it working.

@alexcjohnson alexcjohnson reopened this Nov 29, 2023
@Worschi
Copy link
Author

Worschi commented Nov 29, 2023

Hi @alexcjohnson, fine with me. I am not sure when/if I'll be able to investigate further. The team already moved on and, for now, settled with not having dashed lines.

@kussshhhh
Copy link

@alexcjohnson is this issue still open?

@Coding-with-Adam
Copy link
Contributor

hi @kussshhhh
Yes, this issue is still open

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

5 participants