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

Color cycles for Bokeh charts #2158

Closed
schultzmattd opened this issue Apr 8, 2015 · 1 comment · Fixed by #2267
Closed

Color cycles for Bokeh charts #2158

schultzmattd opened this issue Apr 8, 2015 · 1 comment · Fixed by #2267
Assignees
Milestone

Comments

@schultzmattd
Copy link

I noticed that whenever I try to use the bokeh.charts.BoxPlot function I hit an error with plots with more than 6 boxplots.

import numpy as np from bokeh.charts import BoxPlot test = {} for i in range(0,7): test[str(i)] = np.random.normal(0,1,100) plot = BoxPlot(test) show(plot)

This is the resulting stacktrace:

Traceback (most recent call last): File "temp.py", line 6, in <module> plot = BoxPlot(test) File "/usr/local/lib/python2.7/site-packages/bokeh/charts/builder/boxplot_builder.py", line 84, in BoxPlot xscale=xscale, yscale=yscale, xgrid=xgrid, ygrid=ygrid, **kw File "/usr/local/lib/python2.7/site-packages/bokeh/charts/_builder.py", line 42, in create_and_build chart.add_builder(builder) File "/usr/local/lib/python2.7/site-packages/bokeh/charts/_chart.py", line 118, in add_builder builder.create(self) File "/usr/local/lib/python2.7/site-packages/bokeh/charts/_builder.py", line 169, in create chart.add_renderers(self, renderers) File "/usr/local/lib/python2.7/site-packages/bokeh/charts/_chart.py", line 113, in add_renderers self.renderers += renderers File "/usr/local/lib/python2.7/site-packages/bokeh/charts/builder/boxplot_builder.py", line 283, in _yield_renderers line_color="black", fill_color=self.palette[i]) IndexError: list index out of range

It appears that whatever predefined color list for the BoxPlot function has run out of colors for new boxplots.

Is there a way to either define a new color list (ideally, a cycle that will simply repeat colors if it runs out) or disable coloring entirely?

@fpliger fpliger added this to the 0.9 milestone Apr 9, 2015
@fpliger
Copy link
Contributor

fpliger commented Apr 9, 2015

This is definitely a bug but you can bypass it by specifying a custom palette all the colors you want. If you specify a palette long enough you'll avoid stepping this bug. Here's a quick workaround to make your code work while this isn't fixed:

import numpy as np
from bokeh.charts import BoxPlot
from bokeh.charts.utils import cycle_colors
test = {}
for i in range(0,10):
    test[str(i)] = np.random.normal(0,1,100)
palette = cycle_colors(test)
plot = BoxPlot(test, palette=palette)
show(plot)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants