I have been trying for a long time to dynamically add/remove factors in a categorical plot. I thought changing the datasource would be enough, but it does not. Manually updating the figure x_range already gets me (what seems to be) a
step closer because the factors appear but the extra glyphs still do not appear. It seems to only work when the number of factors stays the same. Changing which factors are displayed works but not changing the number of factors. I guess something else needs to be manually updated but what that something is is beyond me. The only workaround I have found so far is to completely recreate the plot when I need to change the factors, but it’s obviously slower and brings noticeable lag for larger plots.
I have put together a minimal self-contained example at: https://gist.github.com/gdementen/1b34dc4ddbaa55f8678900be6a3bed6f
It has a combobox to change the data shown but not the factors (and this works great!) and buttons to toggle which factors to show (and I haven’t been able to make that part work short of the above mentioned workaround).
Any help would be greatly appreciated !