Python 中的散景包:如何使用 rgb 颜色选项
Bokeh package in Python: How to use rgb to color option
假设我有以下代码:
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)
我试图在文档中查找如何使用 rgb 值存储 color
但找不到。我的意思如下:
p.circle(-25,25, radius=5, color=[0,0,0], alpha=0.8)
有实现的方法吗?
bokeh
支持多种颜色输入方式:
- 已命名的颜色(例如
green
或 blue
)
- RGB 十六进制值,如
#FF3311
- 三元组表示 RGB 值,如
(0, 0, 0)
- 4 元组表示 RGB-Alpha 值,如
(0, 0, 0, 0.0)
所以对于你来说,你可以这样调用你的函数:
p.circle(-25, 25, radius=5, color=(0, 0, 0), alpha=0.8)
此行为在 bokeh
文档的 Styling - Specifying Colors 部分中定义。
我这里有示范代码:
#!/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)
它生成如下图:
你上面的代码,当我运行这个:
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)
生成这个:
假设我有以下代码:
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)
我试图在文档中查找如何使用 rgb 值存储 color
但找不到。我的意思如下:
p.circle(-25,25, radius=5, color=[0,0,0], alpha=0.8)
有实现的方法吗?
bokeh
支持多种颜色输入方式:
- 已命名的颜色(例如
green
或blue
) - RGB 十六进制值,如
#FF3311
- 三元组表示 RGB 值,如
(0, 0, 0)
- 4 元组表示 RGB-Alpha 值,如
(0, 0, 0, 0.0)
所以对于你来说,你可以这样调用你的函数:
p.circle(-25, 25, radius=5, color=(0, 0, 0), alpha=0.8)
此行为在 bokeh
文档的 Styling - Specifying Colors 部分中定义。
我这里有示范代码:
#!/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)
它生成如下图:
你上面的代码,当我运行这个:
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)
生成这个: