Can the line dash of a segment plot be defined by source data?

蓝咒 提交于 2019-12-23 17:08:13

问题


Can the line_dash parameter of a segment plot depend on the source data?

data = {}
data["dash"] = ["dashed","dashed","solid"]
data["x0"] = [0,1,2]
data["x1"] = [5,6,8]
data["y0"] = [1,1,1]
data["y1"] = [2,1,2]
source = bokeh.models.ColumnDataSource(data)
plot.segment(x0="x0", y0="y0", x1="x1", y1="y1", line_dash="dash", source=source)

Returns

ValueError: expected an element of either Enum('solid', 'dashed', 'dotted', 'dotdash', 'dashdot'), Regex('^(\d+(\s+\d+)*)?$') or Seq(Int), got 'dash'

Can the line_dash property be only set to one value? How do I know which parameters can be set "locally" and which have to be set "globally"?


回答1:


The line_dash property is not currently "vectorizable" in the way that many other properties (e.g. color, alpha, position, etc.) are. You can look in the Reference Guide for Segment.line_dash and see that its property type is DashPattern. All the properties that are vectorizable will have "Spec" in the type name, e.g Segment.line_alpha has a property type NumberSpec, so that indicates that you can set the alpha value to either one number, or it can refer to a list of numbers in a ColumnDataSource to vectorize different alphas.

It's possible this situation could be change, there has just never been any evident demand for it, so it was not prioritized. Feel free to make a Github feature request issue to discuss further.



来源:https://stackoverflow.com/questions/50527488/can-the-line-dash-of-a-segment-plot-be-defined-by-source-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!