Guest User

Untitled

a guest
Jan 18th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. from bokeh.io import show, output_file
  2. from bokeh.models import ColumnDataSource
  3. from bokeh.plotting import figure
  4. from bokeh.transform import factor_cmap
  5. from bokeh.palettes import Spectral6, Dark2
  6.  
  7. output_file("colormapped_dots.html")
  8.  
  9. cats = ['A', 'A', 'B', 'B', 'C', 'C']
  10. x = [5, 3, 4, 2, 4, 6]
  11. y = x
  12. factors = list(set(cats))
  13. source = ColumnDataSource(data=dict(cats=cats, x=x, y=y))
  14.  
  15. p = figure()
  16. p.circle('x', 'y', size=10,
  17. color=factor_cmap('cats', palette=Spectral6, factors=factors),
  18. source=source)
  19. show(p)
  20.  
  21. p = figure()
  22. p.circle('x', 'y', size=10,
  23. color=factor_cmap('cats', palette=Dark2, factors=factors),
  24. source=source)
  25. show(p)
  26.  
  27.  
  28. ValueError: expected an element of Seq(Color), got {3: ['#1b9e77', '#d95f02', '#7570b3'], 4: ['#1b9e77', '#d95f02', '#7570b3', '#e7298a'], 5: ['#1b9e77', '#d95f02', '#7570b3', '#e7298a', '#66a61e'], 6: ['#1b9e77', '#d95f02', '#7570b3', '#e7298a', '#66a61e', '#e6ab02'], 7: ['#1b9e77', '#d95f02', '#7570b3', '#e7298a', '#66a61e', '#e6ab02', '#a6761d'], 8: ['#1b9e77', '#d95f02', '#7570b3', '#e7298a', '#66a61e', '#e6ab02', '#a6761d', '#666666']}
Add Comment
Please, Sign In to add comment