Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symlog scale leads to weird results #3788

Open
3 tasks done
aplavin opened this issue Apr 17, 2024 · 6 comments
Open
3 tasks done

Symlog scale leads to weird results #3788

aplavin opened this issue Apr 17, 2024 · 6 comments

Comments

@aplavin
Copy link
Contributor

aplavin commented Apr 17, 2024

I’m trying to plot a 2d array with both positive an negative values, using a “symlog” colorscale in Makie.

This is what I get, looks weird – I cannot make any sense out of colorbar labels:

And this is what I expected it to be – result from matplotlib for the same array for comparison:

My issue here is with the colorscale specifically, not any other visual difference between Makie and matplotlib.

Full code for both:

# Makie:
let
	fig, ax, plt = image(A, colorscale=Makie.Symlog10(0.1), interpolate=false, colormap=:viridis)
	Colorbar(fig[1,2], plt)
	fig
end

# PyPlot:
let
	plt.figure()
	plt.imshow(A, norm=matplotlib.colors.SymLogNorm(0.1))
	plt.colorbar()
	plt.gcf()
end
  • are you running newest version (version from docs) ? – yes
  • can you reproduce the bug with a fresh environment ? (]activate --temp; add Makie) – yes
  • What platform + GPU are you on? – Any backend, same result.
@aplavin aplavin added the bug label Apr 17, 2024
@jkrumbiegel
Copy link
Member

ok so I think the labels are explained such that the linear tick finder is applied, which sees limits from about -2 to 1. So you get ticks -2, -1, 0, 1 but in the symlog scaling, -1, 0 and 1 for some reason all go on top of each other. That I don't understand

@aplavin
Copy link
Contributor Author

aplavin commented Apr 17, 2024

Colors themselves also seem wrong in general...
Another random realization of the same code:
Makie
image

Matplotlib
image

@asinghvi17
Copy link
Member

asinghvi17 commented Apr 20, 2024

What happens if you try pseudolog?

@aplavin
Copy link
Contributor Author

aplavin commented Apr 21, 2024

Pseudolog displays fine, but it's not symlog :) Most importantly, it lacks the parameter that decides on where log-scale effectively starts.
I think the issue is just in the Makie Symlog function, not sure where the formula is taken from – but appears very different from matlab/matplotlib at least.
Played with the symlog function I wrote quite some time ago for different purposes,

function symlog(x; linthresh, base=10., linscale=1.)
    linscale_adj = linscale / (1 - base^-1)
    if abs(x) < linthresh
        return x * linscale_adj
    else
        return sign(x) * linthresh * (linscale_adj + log(base, abs(x) / linthresh))
    end
end

– it seems to work fine as a scale in Makie.

@jkrumbiegel
Copy link
Member

I don't remember anymore where I got the formula from, if I didn't come up with it myself from my understanding of what symlog should do. If it turns out to be incorrect, let's change it by all means.

@asinghvi17
Copy link
Member

I believe the Symlog10 function actually constructs a Makie.ReversibleScale object - making that more extensible would be great as well! Maybe something like Symlog(linthresh, base = 10., linscale = 1.) which returns a ReversibleScale would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants