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

Scatter text automatic colour #2018

Closed
slishak opened this issue Sep 19, 2017 · 4 comments
Closed

Scatter text automatic colour #2018

slishak opened this issue Sep 19, 2017 · 4 comments

Comments

@slishak
Copy link

slishak commented Sep 19, 2017

When plotting a scatter with mode 'lines+markers' with no colour specified (i.e. automatic sequential colouring), both the lines and the markers have the same colour. When extending this to 'lines+markers+text', the markers and lines are still the same colour but the text is always black.

At the point I'm defining the scatter, I don't know what colour the line will be (as I'm relying on plotly to do this for me).

Is there any way to make the text the same colour as the lines and markers when the actual colour is not user-specified?

@alexcjohnson
Copy link
Collaborator

No, there's no way to do this. I can only suggest setting these colors manually. If you want to use Plotly's defaults (glad you like them!) I don't believe they're exposed anywhere normally but you can grab them from here.

In principle we could add this as a feature (textfont.color: 'inherit'?), but it strikes me as a fairly uncommon edge case - most of the time it seems to me you need text to have a different color so it's still legible when it overlaps other markers/lines.

@slishak
Copy link
Author

slishak commented Sep 20, 2017

I do like the default colours - and I think my solution might be to grab them from that link, thanks for that.

For a bit more information on my use case, I'm using Dash (my new favourite toy) to build a tool that allows the user to interactively plot families of parametric curves {x=u(t), y=v(t)}, and I'd like to annotate the parameter value at a few pre-determined points along each curve. When the curves approach and overlap it would be neater if each text label was easily associated with its line/marker by colour.

@etpinard
Copy link
Contributor

Request like this one come up quite frequently.

Maybe we should output the default trace color sequence in Plotly.PlotSchema.get() - which would make it accessible to the python and R APIs.

@etpinard
Copy link
Contributor

etpinard commented May 14, 2018

Maybe we should output the default trace color sequence in Plotly.PlotSchema.get()

After the colorway PR (-> #2156), users can now grab the default trace color sequence with:

Plotly.PlotSchema.get().layout.layoutAttributes.colorway.dflt

Closing.

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

No branches or pull requests

3 participants