transform_markers#
使用Palmer企鹅数据集的散点图。此示例展示了使用基本绘图元素进行颜色和标记映射。图表显示了三种不同企鹅物种的体重与鳍状肢长度之间的相关性。
详情
- Sampledata:
- Bokeh APIs:
figure.scatter
,bokeh.transform.linear_cmap
,bokeh.transform.factor_mark
- More info:
- Keywords:
alpha, 颜色映射, 标记映射, 散点图
from bokeh.plotting import figure, show
from bokeh.sampledata.penguins import data
from bokeh.transform import factor_cmap, factor_mark
SPECIES = sorted(data.species.unique())
MARKERS = ['hex', 'circle_x', 'triangle']
p = figure(title = "Penguin size", background_fill_color="#fafafa")
p.xaxis.axis_label = 'Flipper Length (mm)'
p.yaxis.axis_label = 'Body Mass (g)'
p.scatter("flipper_length_mm", "body_mass_g", source=data,
legend_group="species", fill_alpha=0.4, size=12,
marker=factor_mark('species', MARKERS, SPECIES),
color=factor_cmap('species', 'Category10_3', SPECIES))
p.legend.location = "top_left"
p.legend.title = "Species"
show(p)