question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handle log colormapping change in bokeh 2.0

See original GitHub issue

Example of the issue as reported by K.-Michael Aye on gitter:

image

Bokeh 2.x no longer lets the log colormapper handle zeros. I understand the goal of this change was to address this issue https://github.com/bokeh/bokeh/issues/8061 (also see the discussion here https://github.com/bokeh/bokeh/issues/8724). This problem can be more easily avoided when using floats as you can use NaN to avoid the log zero issues.

Unfortunately, this fix will cause a lot of confusion as illustrated by the screenshot above. After discussing this with @jbednar, we listed the following ways we could address this:

  1. Document this issue and update how to use clim appropriately, checking and updating all our notebooks and handling all the confusion caused to users who miss the updated docs.

  2. Maintain backwards compatibility somehow in bokeh 2.0, stating that our logz semantics match Bokeh > 2.0 and offer a new option for the better behavior (the old behavior resulted in incorrect colorbars). I’m not sure how this could be achieved technically if the old behavior is not available in bokeh 2.x anymore…

  3. Somehow support a masking approach at the element level (i.e Image at least, and that could be generalized to other elements?). Seems like a whole lot of work…

  4. Address this for the most common use case which will be for any datashading operation that returns zero integers (e.g count). To do this you have to avoid generating integers in the first place as NaN isn’t a valid integer: the idea would be to cast integer arrays to float and replace all zeros with NaNs.

If it isn’t already obvious, I am in favor of option 4 (and maybe option 2, if it is possible) as it would fix the problem in the majority of cases without having to update all the notebooks and inform all affected users. Although I don’t think this is ideal (I would prefer to keep count dtypes as integer) this transformation doesn’t violate datashader semantics where NaN and zero are equivalent. Maybe we could have an option for the operations (default off) to skip this transformation for people who want to preserve integer types?

Unfortunately, I don’t see any easy solutions and nothing that doesn’t involve documenting this change in behavior in Bokeh 2.0 somewhere. What are your thoughts @philippjfr ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
philippjfrcommented, Apr 13, 2020

I would also vote for throwing a warning in case the clim gets cut off at 1 for integers.

Are you sure this is really needed? What is the alternative here? A zero value can never be displayed in the log color mapper so a lower bound of 1 is the only possible default lower bound for ints.

2reactions
philippjfrcommented, Apr 10, 2020

My opinion is that we should warn if the log color mapper encounters a zero value and tell the user to set a clim lower bound. Another option is that if we encounter an integer array we can automatically set the lower bound of the log range to 1 but warn if a float is used since it’s not obvious how to choose a default lower bound.

Somehow support a masking approach at the element level (i.e Image at least, and that could be generalized to other elements?). Seems like a whole lot of work…

We absolutely should do this as it’s needed for masking integer arrays in linked selections. Not sure how quickly we can do this however.

If it isn’t already obvious, I am in favor of option 4 (and maybe option 2, if it is possible) as it would fix the problem in the majority of cases without having to update all the notebooks and inform all affected users.

I’m -1 on both 2 and 4 tbh. There was a reason that log1p was disabled in bokeh because it was effectively wrong in many cases. I’m also not too happy casting ints to floats really.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Styling visual attributes — Bokeh 2.4.3 Documentation
Once you have created a colormap, you can use it with the color attribute of many plot objects from bokeh.plotting. Bokeh includes several...
Read more >
Pandas Bokeh Visualization Tutorial - Kaggle
In this kernel notebook I will be focusing on initially covering the new Pandas_Bokeh Data visualisation followed by a exploratory data analysis ,a...
Read more >
How do I get colors on a bokeh plot to line up with their correct ...
I am trying to theme points on a bokeh plot with a log scale coloring scheme, and have a colorbar that goes along...
Read more >
Interactive Data Visualization with Bokeh - Trenton McKinney
In this exercise, you'll plot a line and circle glyph for the AAPL stock prices. Further, you'll adjust the fill_color keyword argument of...
Read more >
Working with Plot and Renderers — HoloViews v1.15.3
p = hv.render(curve, backend='bokeh') print(type(p)) ... These allow defining hooks which modify a plot after it has been rendered in the backend but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found