Let Scatter marker type be parameterizable
See original GitHub issueI keep running into an issue with markers where there is a need to vary marker according to some attribute of the data. As far as I understand it, this can only be done by splitting the data up into different data sources and making separate GlyphRenderers for each marker. This is problematic for several reasons.
Take this example, where I’m varying color and marker according to a variable in the data:
As illustrated above, one of the problems with breaking the data up and specifying multiple GlyphRenderers is that when you allow tap selection, the selection is restricted to only that group / marker. There are several related issues dealing with the various tools and callbacks when you want to think of the entire set of markers as a whole. The bigger issue is that it makes things a lot more complicated at the interface level for dealing this special case (in particular, it makes things pretty messy inside rbokeh).
To me, the ideal solution would be instead of individual classes “Circle”, “Square”, etc., having a class “Marker” that has an attribute “marker” that can be any one of: “Asterisk”, “Circle”, “CircleCross”, “CircleX”, “Cross”, “Diamond”, “DiamondCross”, “InvertedTriangle”, “Square”, “SquareCross”, “SquareX”, “Triangle”, “X”. As far as I understand, all of the current marker classes have the same attributes, so it seems like this would be possible.
So basically instead of having a specification with things like this:
{
"type": "GlyphRenderer",
"attributes": {
"glyph": {
"type": "Circle",
...
}
}
},
{
"type": "Circle",
"attributes": {
"x": {
"units": "data",
"field": "x"
},
"y": {
"units": "data",
"field": "y"
},
...
}
}
{
"type": "GlyphRenderer",
"attributes": {
"glyph": {
"type": "Square",
...
}
}
},
{
"type": "Square",
"attributes": {
"x": {
"units": "data",
"field": "x"
},
"y": {
"units": "data",
"field": "y"
},
...
}
},
...
With each having a separate ColumnDataSource. Instead, something like this would make life so much easier:
{
"type": "GlyphRenderer",
"attributes": {
"glyph": {
"type": "Marker",
...
}
}
},
{
"type": "Marker",
"attributes": {
"x": {
"units": "data",
"field": "x"
},
"y": {
"units": "data",
"field": "y"
},
"marker": {
"units": "data",
"field": "m"
},
...
}
},
{
"type": "ColumnDataSource",
"attributes": {
"column_names": ["x", "y", "m"],
"data": {
"x": [1, 2, 3],
"y": [1, 2, 3],
"m": ["Circle", "Square", "Triangle"],
...
}
}
},
...
Where here there is a single data source.
If this is not possible or not a priority, is there any way with the current structure of things that I can have a single ColumnDataSource with multiple markers?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (7 by maintainers)
Top GitHub Comments
FYI @hafen this is incoming:
OK, the newly linked issue has made me re-consider. In cases where folks want multiple lines and scatter glyphs together, not having a “multi glyph” can be quite slow.