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

viz: Should a linear scaling be used automatically when the value range is narrow ? #3537

Closed
neutrinoceros opened this issue Oct 1, 2021 · 1 comment
Labels
enhancement Making something better question viz: 2D

Comments

@neutrinoceros
Copy link
Member

Trying to fix #3229 makes me think that it could be an opportunity to make norm selection a little more clear, and in particular it seems like a good time to propose a new rule.
So here's an example to illustrate how our current scale selection rules can be damaging for data readability

import numpy as np
import yt

d = {'my_fake_density': np.random.random_integers(1, 3, size=(64,64,64))}

ds = yt.load_uniform_grid(d, [64,64,64])
p = yt.SlicePlot(ds, "z", ('stream', 'my_fake_density'))
p.set_log(('stream', 'my_fake_density'), True, linthresh=1.e-3)
p.set_zlim(('stream', 'my_fake_density'), -1, 1)
p.save()

output:
UniformGridData_Slice_z_my_fake_density
The default colorscale is actually pretty obscure because a log norm isn't appropriate here.
(note: I've used my branch #3536 to produce this picture to avoid distraction from an unrelated colorbar bug)

Using yt's main branch

UniformGridData_Slice_z_my_fake_density

)

As an easy fix to the issue above, I'm proposing that we use linear scaling by default instead of log on the condition that the value range is below 2 orders of magnitude. I believe this can be achieved at the same time as a fix to #3229.

Of course this criterion isn't sufficient and it would also make sense to compare the variance of the image VS the variance of its log, but I don't really like the idea of piling up layers of magic here, as the existing norm-selection mechanism is already proving difficult to maintain against a large range of matplotlib versions.
In an ideal world, we should expose the color norm completely so all of matplotlib's flexibility is available to our users.
I would like to do that in the future, but for now I want to focus on having sensible defaults.

@neutrinoceros
Copy link
Member Author

arguably the example in the OP is terribly malformed, I don't think it's illustrating the point correctly now so I'd rather close it and maybe reopen when things stabilise with matplotlib 3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Making something better question viz: 2D
Projects
None yet
Development

No branches or pull requests

1 participant