lab-cosmo / chemiscope

An interactive structure/property explorer for materials and molecules
http://chemiscope.org
BSD 3-Clause "New" or "Revised" License
121 stars 29 forks source link

Fix for log/inverse/sqrt color scale in map plot #278

Closed angerossi closed 1 year ago

angerossi commented 1 year ago
ceriottm commented 1 year ago

OK, I'm testing this. Two first observations:

  1. it looks like proper logarithmic colorscale labels can be generated see https://plotly.com/python/colorscales/#customizing-tick-text-on-logarithmic-color-bars
  2. the error message says that negative values are mapped to gray, but actually they are shown with the color corresponding to the minimum of the scale
Luthaf commented 1 year ago

it looks like proper logarithmic colorscale labels can be generated see https://plotly.com/python/colorscales/#customizing-tick-text-on-logarithmic-color-bars

This is possible, but mainly works if the data spans multiple orders of magnitude. If all values are between 1 and 3, creating log-spaced ticks is a bit harder.

angerossi commented 1 year ago

it looks like proper logarithmic colorscale labels can be generated see https://plotly.com/python/colorscales/#customizing-tick-text-on-logarithmic-color-bars

I did have a look at this. While it is possible, the ticktest argument requires that the tickmode is set to array, such that the tickvals are set in the layout. Also, the alternative implementation with the labelalias argument allows for any tickmode, but the tickvals are still required to set the aliases. Since we set the min and max for the colorbar, Plotly automatically sets the tickvalues and extracting them is non-trivial.