Add a Figure.contour method
See original GitHub issueSince MultiPolygons
have landed, we should be able to support filled contours. Filled contours should be composed of multiple polygons each of which can have holes. Levels of contours should never overlap with each other - every new level that is contained within the bounds of a level should be a hole. This will make hover and tap tools great and makes sense conceptually if we think about elevation because no x, y has multiple elevations.
My original attempts at determining which polygons contain which others is contained in this notebook - but holoviews now has the concept of holes, so it should be more straightforward: https://anaconda.org/jsignell/contouring_with_holoviews/notebook
We can probably borrow most of the logic from holoviews if we want to depend on matplotlib. Otherwise there is a scikit-image method as well.
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (11 by maintainers)
Top GitHub Comments
We have had quite a lot of contouring discussion over the last 6 months, spread over slack, discourse and github. Perhaps this is a good time and place to summarise the situation from my point of view.
I am the author of the Matplotlib contouring algorithm. I am working on a new project (https://github.com/contourpy/contourpy) to package up the original (2005) MPL C algorithm, the current (2014) C++ one and a new C++ one that I am working on that is both faster and uses less RAM than the current MPL one (if used sensibly). The idea is that Python projects will have access to contouring without having to have MPL as a dependency. My primary objective is to add contouring to Bokeh, but of course other Python projects will be welcome to use it and I expect MPL to adopt it.
This will be on the Python side of Bokeh. The Bokeh API is TBD, but I expect the contour lines at a particular level to be passed to bokehjs as a MultiLine, probably with some extra data to indicate the contour level. Similarly, filled contours between two levels would be passed to bokehjs as a MultiPolygon. The calculations stay on the Python side and the JavaScript side allows the usual interactivity of zooming, panning, selection, highlighting, etc.
Porting the algorithm to JavaScript might be an interesting project for someone, but I don’t expect it to run fast enough to be workable.
People often mention skimage’s find_contours and other similar “image contouring” algorithms, but they suffer from two problems:
The path of least resistance for Bokeh is to let me get
contourpy
to a state that I am happy with and deal with all the inconvenient packaging issues, then ensure the Bokeh API is sensible, and you will get contouring in a few months with very little effort required (other than by me!)closed by #12020