Last active
August 29, 2015 14:20
-
-
Save rothnic/e655dc566f848bae4246 to your computer and use it in GitHub Desktop.
Bokeh Alpha Testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bokeh.plotting as plt | |
from itertools import product | |
plt.output_file('test.html') | |
alpha = 0.5 | |
circle_size = 50 | |
line_size = 5 | |
cats = ['RGB', 'RGBA', 'Alpha+RGB', 'Alpha+RGBA'] | |
p = plt.figure(x_range=cats, y_range=cats) | |
fill_color = (255., 0., 0.) | |
fill_color_alpha = (255., 0., 0., alpha) | |
line_color = (0., 255., 0.) | |
line_color_alpha = (0., 255., 0., alpha) | |
fill = [(1, {'fill_color': fill_color}), | |
(2, {'fill_color': fill_color_alpha}), | |
(3, {'fill_alpha': alpha, 'fill_color': fill_color}), | |
(4, {'fill_alpha': alpha, 'fill_color': fill_color_alpha})] | |
line = [(1, {'line_color': line_color}), | |
(2, {'line_color': line_color_alpha}), | |
(3, {'line_alpha': alpha, 'line_color': line_color}), | |
(4, {'line_alpha': alpha, 'line_color': line_color_alpha})] | |
combinations = product(fill, line) | |
for comb in combinations: | |
this_fill, this_line = comb | |
x, fill_options = this_fill | |
y, line_options = this_line | |
options = fill_options.copy() | |
options.update(line_options) | |
p.circle(x, y, line_width=line_size, size=circle_size, **options) | |
p.xaxis[0].axis_label = "Fill Options" | |
p.yaxis[0].axis_label = "Line Options" | |
p.title = "Fill and Line Option Combinations" | |
plt.show(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment