# Why is this legend going into party mode rotating across colors when using a slider with a callback?

**URL:** <https://discourse.bokeh.org/t/why-is-this-legend-going-into-party-mode-rotating-across-colors-when-using-a-slider-with-a-callback/4544>\
**Category:** Community Support\
**Created:** [January 18, 2020, 2:47am UTC](https://discourse.bokeh.org/t/why-is-this-legend-going-into-party-mode-rotating-across-colors-when-using-a-slider-with-a-callback/4544 "2020-01-18T02:47:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![carolyn](https://discourse.bokeh.org/user_avatar/discourse.bokeh.org/carolyn/32/1316_2.png) [@carolyn](https://discourse.bokeh.org/u/carolyn)\
**Post date:** [January 23, 2020, 4:03am UTC](https://discourse.bokeh.org/t/why-is-this-legend-going-into-party-mode-rotating-across-colors-when-using-a-slider-with-a-callback/4544/2 "2020-01-23T04:03:58Z")

</div>

Hi tvkyq,

It’s possible-- not yet definite-- that there may be a bug here in the way that categorical legends behave when CDSViews are involved. I need to work up a minimal example to prove it, and decide what elements are important to the problem; my testing so far suggests that the factor\_cmap isn’t an issue, and if we instead add a column of explicitly defined colors to your data source, the same thing occurs. Anyway, I’ll be working on that and submitting a GitHub issue if we do determine that it’s not behaving like it ought, and I’ll update this thread with a link to that GH issue.

In the meantime, we have a couple options for workarounds. We could revisit the original example you cited in your [other post](https://discourse.bokeh.org/t/how-to-get-a-drop-down-to-change-axes-i-thought-this-would-work-but-i-dont-understand-why-not/4522), the example in which a new figure is being drawn on each update. That’s possible, but I imagine your real-life end goal is more complicated than the apples, bananas, and oranges you have here, and I’d be wary about scaling.

Perhaps a better option would be to avoid using a CDSView, instead using your original data to construct one large, source-of-truth CDS. Then, with each update, your callback would build a CDS that’s a subset of that untouched original. The subset CDS could then be assigned to be the data source for your circle glyph.

I hope that makes sense, with the caveat that I have not built a working example of it. I believe it will get around this issue of the grouped categorical legend and the colors assigned to legend items not matching up. Please give it a shot and let us know what questions you have along the way. Thanks for your patience while this was investigated!

---

_[View the full topic](https://discourse.bokeh.org/t/why-is-this-legend-going-into-party-mode-rotating-across-colors-when-using-a-slider-with-a-callback/4544)._
