New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explicitly warn that CDSView is unsupported on line glyphs #9388
Comments
I'm not actually sure that CDSView together with lines can be considered supported at present. AFAIK the behavior is not well-defined or ideal in the presence of a connected topology. Ideally subsetting line data would result in multiple disjoint polylines anywhere the view leaves contiguous groups of points, split wherever points were excluded in between the groups. It definitely doesn't do that now, and if it did you'd also be left with the question of what to do with isolated points. So to the extent it does anything now, I think it just draws a single polyline through all remaining points, whether they were adjacent originally or not. I would regard this as accidental and not explicitly intentional, as that is (IMO) a questionable thing to do from a visualization perspective. FWIW in the particular example above, I think line is not a good choice since this is not time series data (model years are discrete and categorical, really) and lines imply intermediate values that simply do not exist. Using views as they are now, only compounds that problem. If views behaved ideally on lines as I described I don't think any lines woudl get drawn at all (all the points would be isolated). A Scatter, Dot Plot, or Bar Graph would all be improvements here (that would also function with views). If you really want lines in this case I am inclined to say that it's better to extract the subsets you want (in Python) and call I'm fairly inclined to punt on this, or if any action is taken at all, to make Bokeh warn or error when views are used with lines, stating clearly that this combination is unsupported. cc @bokeh/dev for thoughts |
FWIW, I would definitely prefer an error or a warning here. Also it may be worth pointing out that if a user wants to change views/filters via some UI controls in order to toggle some lines' visibility, it would probably make sense to use |
I understand that CDSView combined with lines has some (conceptual) issues, as discussed in issue #7070. In fact, this is why I need the Concerning the appropriateness of line plots, they provide the greatest visual clarity for exploratory data analysis in my use case. @p-himik I see that multi_lines is indeed able to produce the plots I'm looking for, using views, with independent y-ranges. However, the structure of the CDS needs to be different. This would inhibit having common CDS and views (in a parent class) used for different plot types (in various child classes). For example, a CDS like {'value0': [4, 6, 7, 0.8, 0.2, 0.3],
'value1': [4, 5, 6, 0.7, 0.8, 0.4],
'x': [0, 1, 2, 0, 1, 2],
'subplot': ['left', 'left', 'left', 'right', 'right', 'right']} can be used for {'value': [[4, 6, 7], [0.8, 0.2, 0.3], [4, 5, 6], [0.7, 0.8, 0.4]],
'x': [[0, 1, 2], [0, 1, 2], [0, 1, 2], [0, 1, 2]],
'color': ['blue', 'blue', 'red', 'red'],
'subplot': ['left', 'right', 'left', 'right']} TL;DR I'm really just looking for a way to have flexible plot types with the same underlying CDS structure and identical behavior, e.g. in terms of y-ranges. Otherwise, the second-best approach seem to be independent CDS's per subplot without views. |
Right in this particular case it happens to do something ok-ish (or at least close to what you want). But I think that is a coincidence and not true in general, which means leaving things in a quasi-supported state only invites support issues. I'd rather be unambiguous (with a warning/error) that this combination is simply not supported. Given that, I agree that:
|
This should really raise an exception or something. And the error message didn't even show when I was using I got this warning when running with
But this did not show up with There should also be a big warning message in the docs that states this limitation: https://docs.bokeh.org/en/latest/docs/user_guide/data.html#filtering-data. Already raised here, I guess: #7070 |
@matwilso I would actually expect a CDS view to work with multi-line, though perhaps not in the way you are wanting? A CDS view filters "top" level indices, so for a multiline it would filter out entire sub-lines, since each top-level index in the data for a multi-line corresponds to an entire line. If you are saying that a CDS view does not filter sub-lines of a multi-line, that is a separate concern, please open a new issue with MRE. |
It's alright, I was just frustrated yesterday. I found a different way of doing what I needed. I had a dataframe with indices, where if you index into it, you will get a list of lists like the multi-line api expects. I would expect that cdsview just works in a similar way that it does for other plot types and its surprising that it doesn't I guess idk. Was my first encounter with using cdsview. Anyway, just expressing a signal of something I stumbled over |
@matwilso TBH I still don't understand whether you have run in to an actual bug or not. These discussions are always more focused with a complete Minimal Reproducible Example so there does not have to be speculation. A CDS view should work with multi-line, by acting on entire individual sub-lines. But it's not clear if:
|
Bokeh: 1.3.4
Python: 3.6.8
OS: GNU/Linux x86_64
Browser: Firefox 70.0.1/Chromium 78.0.3904.70
Figures containing line glyphs generated from the same ColumnDataSource with different CDSViews share the same initial y axis range (however, they pan and zoom independently).
This is not the case for other plot types like circles, areas, bars (independent y range adapted to data ranges for each figure separately).
Expected behavior
Example 1: Line plots and views --> produces unexpected result
Example 2: Circle plots and views --> produces expected result
Example 3: Line plots and separate sources --> produces expected result
The text was updated successfully, but these errors were encountered: