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

sliceplot symlog regression 3.6 - 4.0 #3726

Closed
zingale opened this issue Dec 16, 2021 · 6 comments
Closed

sliceplot symlog regression 3.6 - 4.0 #3726

zingale opened this issue Dec 16, 2021 · 6 comments
Assignees

Comments

@zingale
Copy link
Member

zingale commented Dec 16, 2021

Bug report

Bug summary

if I specify a symmetric data range like:

sp.set_zlim("density", -1.e13, 1.e13)

yt 3.6.1 respect that range, and scales the data in it, giving something like this:

yt-3 6 1

Notice that the choice of the colormap was made such that 0 is white -- this is desired for visualizing this data.

Here's the output for yt 4.1.dev0

yt-4 1

Notice that it ignores the lower data range and instead scales to the data, making white no longer "0"

Code for reproduction

Here's a simple code to make these plots:

import numpy as np
import yt

data = np.exp(30*np.random.random((40, 40, 40)))

mask = np.random.random(data.shape)


data[mask < 0.5] = -data[mask < 0.5] / 100

print(data.min(), data.max())


data_arr = dict(density=(data, "g/cm**3"))
bbox = np.array([(0, 20), (0, 20), (0, 20)])
ds = yt.load_uniform_grid(data_arr, data.shape, bbox=bbox)


sp = yt.SlicePlot(ds, "z", ("gas", "density"))
sp.set_log("density", True, linthresh=1.e6)
sp.set_zlim("density", -1.e13, 1.e13)
sp.set_cmap("density", "bwr")

sp.save("test.png")
# Paste your code here
#
#

Actual outcome

# If applicable, paste the console output here
#
#

Expected outcome

Version Information

  • Operating System:
  • Python Version:
  • yt version:
  • Other Libraries (if applicable):
@matthewturk
Copy link
Member

@zingale this is interesting -- thanks for reporting. @neutrinoceros I believe this may be related to some of your changes; is it possible to verify that?

@neutrinoceros
Copy link
Member

neutrinoceros commented Dec 16, 2021

@zingale I suspect your local copy is out of date, because your result with the main branch doesn't seem to include #3520

If git clone doesn't fix it, it would be interesting to know what version of Matplotlib you have installed, because on my dev env, I'm getting a satisfying result (white = 0) with your script
test

(I'm running matplotlib 3.5.1, current latest version)

@zingale
Copy link
Member Author

zingale commented Dec 16, 2021

huh... you're right. I was testing on 3 different machines, and I didn't have the last one updated. The conda version doesn't work, but I guess that's okay,, since the change didn't make it in.

Looking at those plots for the minus sign, the 3 changed from a hyphen to a proper minus sign, and now back to a hyphen. Any chance we can fix that and get a proper minus sign back like the middle plot?

@zingale
Copy link
Member Author

zingale commented Dec 16, 2021

I'll close this issue. Thanks @neutrinoceros

@zingale zingale closed this as completed Dec 16, 2021
@neutrinoceros
Copy link
Member

The conda version doesn't work, but I guess that's okay,, since the change didn't make it in.

I think the bugs you saw are indeed in yt 4.0.1, but they'll be fixed in the upcoming 4.0.2 release

Looking at those plots for the minus sign, the 3 changed from a hyphen to a proper minus sign, and now back to a hyphen. Any chance we can fix that and get a proper minus sign back like the middle plot?

I believe this is purely a matter of fonts, #3520 restored the historic style of yt, which was broken with recent versions of matplotlib, so the change back is intentional, in a sense. I don't think we could "fix" this easily without adding a disproportionate amount of technical debt. I think we support changing the font on the user side (I remember some tests were exercising this feature), but I can't find it back.

@neutrinoceros neutrinoceros added wontfix and removed bug labels Dec 16, 2021
@zingale
Copy link
Member Author

zingale commented Dec 16, 2021

ah that's okay then. Thanks for fixing this, and sorry I was out of date.

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

3 participants