I’m trying to create a simple heatmap with a logarithmic colorscale. The documentation for dtick in coloraxis says:
If the axis type is “log”, then ticks are set every 10^(n"dtick) where n is the tick number. For example, to set a tick mark at 1, 10, 100, 1000, … set dtick to 1.
I can’t get this to work and research showed others have this problem as well.
I created a minimal codepen, showing the (not working) logarithmic colorscale:
Am I doing something wrong or is this a bug/not implemented? Should I create a github issue for this?
I was one of those who had the problem I no longer work on that project but my recollection is that we ended up having to create a custom color bar with more ticks so that the bar looked OK for a logarithmic range. Not exactly ideal but it was hoped that a new version of plotly would emerge with a working color scale.
Yeah, that’s also my workaround I was thinking of. There is Logarithmic Color scale with Graph Objects, which shows how to change colors in a logarithmic way. However, the distribution on the colorbar is still linear.
It really seems, a logarithmic colorbar is just not implemented yet
Check this out, the first heatmap is an example that I took from the Python documentation and passed it to javascript and in the second I just adapted your data to the first example.
However, your example doesn’t really use a logarithmic colorscale, but only labels it similar to a logarithmic scale, i.e. “100”, “1000”, “10k”, etc. In a real logarithmic scale, the distances between all these labels would be equal, which is not the case. And the colors for the lower values are condensed at the bottom, you can’t hardly see green or yellow, which is of little use, hence.
A scale I would like would look like this one: , in contrastr to this:
And as far as I can tell, this is currently not possible with plotly, right?
It seems this is what I need. I have to check it out in more details, but looks good.
A minor drawback I see is, the actual z-values have to be translated before passing to Plotly and thus the tooltips have to use customdata to show correct values. Anyway, I think I can live with this for now.
It would be really great if Plotly could do this by itself, without additional JavaScript logic.