Reputation: 4991
Lets say I have the following code:
from bokeh.plotting import *
p= figure(title = 'title',x_axis_label='x',y_axis_label='y')
p.circle(-25,25, radius=5, color="black", alpha=0.8)
show(p)
I am trying to find in documentation how to store color
with rgb values but cant find it. What I mean something like the following:
p.circle(-25,25, radius=5, color=[0,0,0], alpha=0.8)
Is there a way to implement it?
Upvotes: 4
Views: 9437
Reputation: 79901
bokeh
supports color entry using multiple methods:
green
or blue
)#FF3311
(0, 0, 0)
(0, 0, 0, 0.0)
So for you, you could call your function like this:
p.circle(-25, 25, radius=5, color=(0, 0, 0), alpha=0.8)
This behavior is defined in the Styling - Specifying Colors section of bokeh
documentation.
I have sample code here which demonstrates this:
#!/usr/bin/env python
from bokeh.plotting import figure, output_file, show
# output to static HTML file
output_file("circle.html", title="circles")
# create a new plot with a title and axis labels, and axis ranges
p = figure(title="circles!", x_axis_label='x', y_axis_label='y',
y_range=[-50, 50], x_range=[-50, 50])
# add a circle renderer with color options
p.circle(-25, 25, radius=5, color=(0,0,0), alpha=0.8)
p.circle(-10, 5, radius=5, color=(120, 240, 255))
# show the results
show(p)
It generates a plot that looks like this:
Your code above, when I run this:
from bokeh.plotting import figure, output_file, show
output_file("circle.html")
p= figure(title = 'title',x_axis_label='x',y_axis_label='y')
p.circle(-25,25, radius=5, color="black", alpha=0.8)
show(p)
Generates this:
Upvotes: 7