iris#

使用Fisher 鸢尾花数据集的散点图。此示例演示了使用基本绘图元素进行手动颜色映射。该图表显示了三种不同鸢尾花物种的花瓣宽度和长度之间的相关性。

注意

维护此示例是为了历史兼容性。请考虑鸢尾花的替代方案,例如penguins

详情

Sampledata:

bokeh.sampledata.iris

Bokeh APIs:

figure.scatter

更多信息:

散点标记

关键词:

alpha, colormap, scatter

from bokeh.plotting import figure, show
from bokeh.sampledata.iris import flowers

colormap = {'setosa': 'red', 'versicolor': 'green', 'virginica': 'blue'}
colors = [colormap[x] for x in flowers['species']]

p = figure(title="Iris Morphology")
p.xaxis.axis_label = 'Petal Length'
p.yaxis.axis_label = 'Petal Width'

p.scatter(flowers["petal_length"], flowers["petal_width"],
          color=colors, fill_alpha=0.2, size=10)

show(p)