如何使用CDS列设置"line_dash"多线字形? [英] How to use a CDS column to set the "line_dash" of a Multiline glyph?

查看:103
本文介绍了如何使用CDS列设置"line_dash"多线字形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用方法multi_line绘制多线.

I am plotting Multilines with the method multi_line.

from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource

source = ColumnDataSource(data=dict(
        x=[3, 3],
        y=[4, 4],
        xs1=[[1, 2, 3], [2, 3, 4]],
        ys1=[[6, 7, 2], [4, 5, 7]],
        xs2=[[8, 9], [10, 11, 12]],
        ys2=[[6, 7], [7, 8, 9]],        
        color=['red', 'green'],
        width=[5, 1],
        dash=['solid', 'dashed']
    )
)

p = figure(
    plot_width=400, 
    plot_height=400,
    tools='lasso_select,pan,wheel_zoom'
)

p.multi_line(
    xs='xs1',
    ys='ys1',
    source=source,
    color='color',
    line_join='round',
    line_width='width',    # this is working with the column name, despite the documentatio say nothing
    # line_dash='dash'     # this is not working
)

show(p)

可以在多行源CDS上设置coloralphaline_width的列,以便以不同的方式绘制每条线.但这不能应用于line_dash属性.我想将主线设置为solid,将其余部分设置为dashed.

A column for color, alpha or line_width can be set on multilines source CDS in order to plot each line in a different way. But this cannot be applied to the line_dash attribute. I would like to make the main line solid and the rest dashed.

如果我在主要行中使用字形line,那么我将失去性能,因为我需要在每个图上同时更新多个字形.

If I use the glyph line for this main lines then I will lose performance because I need to update more than one glyph at the same time on each plots.

另一方面,我认为文档

On the other hand I think there are something missing in the documentation about line_width because a CDS column can be assigned to this method argument and it works:

alpha (float) – an alias to set all alpha keyword args at once
color (Color) – an alias to set all color keyword args at once
>> line_width (float) - should this be added because it works with CDS columns?

是否可以为line_dash属性分配列?

Is there a way to assign a column for the line_dash attribute?

我没有深入测试其余属性.

I didn´t test the rest of attributes in depth.

推荐答案

尽管您要与MultiLine有关,但这与0.12.16开始).如果您现在想要使用不同的破折号,则必须分别调用line.

Although you are asking in relation to MultiLine, this has the same answer as Can the line dash of a segment plot be defined by source data? which is that "vectorizing" the line_dash property is not currently supported (as of 0.12.16) If you want to have different line dashes for now you will have to make separate calls to line.

这篇关于如何使用CDS列设置"line_dash"多线字形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆