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

Styling a single marker #144

Closed
aderidder opened this issue Dec 24, 2015 · 5 comments
Closed

Styling a single marker #144

aderidder opened this issue Dec 24, 2015 · 5 comments

Comments

@aderidder
Copy link

aderidder commented Dec 24, 2015

Hi,

In a community post I recently enquired whether, in order to change the colour of a single marker in a 10000 marker trace, I'd have to provide the plotly.restyle with a complete array with colours, or whether it's possible to update just a single marker.
Etienne's answer is that at the moment plotly.restyle can only be used to restyle a complete trace.

The feature I'm requesting is a more fine-grained control, e.g. the possibility to change the colour of a single marker without having to style the complete trace.

Thanks,
Sander

@etpinard
Copy link
Contributor

@aderidder Thanks for the suggestion.

I like this idea, but I'm not 100% sure if it belongs in Plotly.restyle.

My main concern is coming up with an API on top of the current Plotly.restyle API that is intuitive, general and scalable.

The current API supports:

// restyle trace 1 in red
// restyle trace 2 in blue
Plotly.restyle('graph', 'marker.color', ['red', 'blue'], [1, 2]);

// restyle trace 1 pts in red and blue in alternate manner
// restyle trace 2 pts in green and yellow " " "
Plotly.restyle('graph', 'marker.color', [['red', 'blue'], ['green', 'yellow']], [1, 2]);

Per-pt restyle could then look like:

// restyle pt 20 of trace 1 in red & pt 21 of trace 1 in blue (and nothing else)
// restyle pt 20 of trace 2 in green & pt 21 of trace 2 in yellow (" " ")
Plotly.restyle('graph', 'marker.color', [['red', 'blue'], ['green', 'yellow']], [1, 2], [20, 21]);

The last argument [20, 21] will be used to restyle both trace 1 and trace 2.

Problem there would no way to e.g. restyle pts 20 and 21 in trace 1 and 10 and 12 in trace 2 in one Plotly.restyle call.

Alternatively, last argument could become a 2d array:

// restyle pt 20 of trace 1 in red & pt 21 of trace 1 in blue (and nothing else)
// restyle pt 10 of trace 2 in green & pt 12 of trace 2 in yellow (" " ")
Plotly.restyle('graph', 'marker.color', [['red', 'blue'], ['green', 'yellow']], [1, 2], [[20, 21], [10, 12]]);

but, that might be too confusing / non-intuitive.

@cldougl @mdtusz thoughts?

@alexcjohnson
Copy link
Collaborator

alexcjohnson commented Jan 30, 2017

#1338 ensures that calls like Plotly.restyle(gd, {'marker.color[23]': 'red'}, null, [0]) will work. Closing this, but note that @etpinard 's concern about restyling different marker indices in different traces is still valid: you cannot change the color of point 23 in trace 0 and point 22 in trace 1 in a single restyle` call. At that point, just use two restyle calls.

@JoaoVitoGomes
Copy link

@alexcjohnson I'm using Plotly.restyle(gd, {'marker.color[23]': 'red'}, null, [0]) in my code but it also change the color of all other markers within the trace. Is there a way for me to stop that?

@alexcjohnson
Copy link
Collaborator

@Discmt can you post a complete code example that shows the issue you've encountered? ie a codepen or something? When I try it, as long as marker.color is already an array, it behaves as expected and only changes the color of one point.

@AniWar
Copy link

AniWar commented Jun 17, 2019

Any definite solution found for this issue ? Can someone please post an sample code .

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

5 participants