Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
I would like to propose this implementation for the
chart.feature_histogram()
function (addressing issue #339).This implementation was manually and visually tested against the GEE JavaScript API example (see images below), Tooltips also work.
It was necessary to import the math library in order to implement the
nextPowerOf2()
function that is required for adjusting the value ofmaxBuckets
andminBucketWidth
in a similar way to what the GEE documentation says.The
start_bins
andend_bins
variables were added to make nicer midpoint offsets and make them as similar as possible to the Google Charts histogram output.This function takes the same input arguments as the GEE JavaScript API equivalent... except for
maxRaw
. I have not found a way to incorporate an equivalent parameter withbqplot
. So far, I have not found a case usingmaxRaw
in the JS API function where the same histogram cannot be reproduced with this function in jupyter (without anymaxRaw
-like input). From the information available in the GEE documentation, I understand thatmaxRaw
only affects the output when calculating a reducer value (but I might be wrong). So the current version of this proposal considers thatmaxRaw
is not necessary for displaying the histogram in Jupyter.I would like to know if this approach is adequate or if there are some other things that I should take care of, in order to be considered for merge.
These changes passed tox tests for python 3.5, 3.6, 3.7, 3.8.
micro-demo
maxBuckets = None, minBucketWidth = None
JavaScript
Python (this function)
maxBuckets = None, minBucketWidth = 0.5
JavaScript
Python (this function)
maxBuckets = 30, minBucketWidth = None
JavaScript
Python (this function)
maxBuckets = 30, minBucketWidth = 3
JavaScript
Python (this function)