chemiscope icon indicating copy to clipboard operation
chemiscope copied to clipboard

Log-scale option in coloring the data points

Open SanggyuChong opened this issue 2 years ago • 11 comments

Hello,

It would be great if an option to take the log of the data for the coloring of data points is available within Chemiscope. Currently, it seems that the user has to save the log of the data manually for this to take place. I was told that this feature was available before -- has there been some decisions against this? Thanks!

Best, Raymond

SanggyuChong avatar Feb 05 '23 22:02 SanggyuChong

That would be fine with me. We would need to change the _colors function https://github.com/lab-cosmo/chemiscope/blob/634136b3d09cc32c9b951d1eb76293b2a872ec9a/src/map/map.ts#L1050

to look more like the _sizes function, likely with a calculateColors function on the map options.

Luthaf avatar Feb 20 '23 14:02 Luthaf

I am reopening this as there are a number of bugs that need to be addressed. For starters, if log is called for a properties that has negative or zero values, it yields an error. That might be a reasonable thing to do, but it should be possible e.g. to set a minimum value >0 and then show this properly. In general, there are a number of quirks related to setting the extremes of the plot range, that make this option basically unusable. The zeolite dataset with volume as a color option is a good example of the problems that occur.

ceriottm avatar Apr 01 '23 13:04 ceriottm

I would try to copy / reuse the behavior and option layout of the Cartesian axes

ceriottm avatar Apr 01 '23 13:04 ceriottm

Ok, it does seem that there are some additional bugs to be fixed and design decisions to be made.

  • Elaborating on what @ceriottm has pointed out, the behavior is different between the cartesian log scale and color log scale in terms of the values that it tries to plot. One critical thing is that when the log scale is invoked in the coloring, it takes the natural log instead of log base 10. Also, the error that it throws when one tries to apply log coloring to volume per Si in the zeolite example (" The inserted values are such that min > max! ...") should not occur.

  • The ticks should become log scale as well in the color bar, but it doesn't and just displays raw exponent values. Behavior of the cartesian axes when log is invoked should be adopted here as well.

  • Regarding the negative values, to me it makes the most sense for us to invoke symlog when negative values are involved. I was quite confused to see the negative values discarded. If it's not too much of a hassle, having a separate symlog option might be nice.

I will follow up with @angerossi and get these taken care of. Thanks all.

SanggyuChong avatar Apr 03 '23 09:04 SanggyuChong

I think that the most important thing is to make sure the behavior (and the UI) is consistent with what happens for Cartesian axes. Adding a symlog function would be nice and perhaps not too hard if we use the same code.

ceriottm avatar Apr 03 '23 11:04 ceriottm

Any progress on fixing the color options for good? It seems to be subtly broken in many different ways.

ceriottm avatar Apr 13 '23 20:04 ceriottm

I have had a meeting with @SanggyuChong and I am currently busy correcting the implementation. It will be finished shortly after the Easter break.

angerossi avatar Apr 14 '23 06:04 angerossi

The ticks should become log scale as well in the color bar, but it doesn't and just displays raw exponent values. Behavior of the cartesian axes when log is invoked should be adopted here as well.

Is this even possible in plotly?

Luthaf avatar Apr 14 '23 10:04 Luthaf

@SanggyuChong we were discussing this today, right? Is this still a problem or can we close the issue?

ceriottm avatar Nov 01 '23 23:11 ceriottm

possibly relevant stackoverflow https://stackoverflow.com/questions/68368745/logarithmic-heatmap-in-plotly

ceriottm avatar Nov 01 '23 23:11 ceriottm

also https://community.plotly.com/t/logarithmic-normalization-for-colorscale-colorbar/44183

ceriottm avatar Dec 01 '23 00:12 ceriottm