-
Notifications
You must be signed in to change notification settings - Fork 272
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
[bug] errors in using log normalization with large data ranges #3170
Comments
@chrishavlin does the fix in #3161 actually fix #2890? |
The following now runs without error on main: import yt
fn = 'FIRE_M12i_ref11/snapshot_600.hdf5'
ds = yt.load(fn)
p = yt.ProjectionPlot(ds, 'x', ('gas', 'density'))
p.save('projection.png') are there more errors? |
Nope! I just want to close #2890!!! |
It seems like the PR addressing this upstream was merged some time ago and is currently only included in Matplotlib 3.5.0rc1, so it should land with Matplotlib 3.5.0. |
Indeed matplotlib/matplotlib#18782 was released in MPL 3.5 |
Bug report
This is an overview of an upstream matplotlib bug and the temporary fix going into yt to address it so that we do not forget to update yt down the line.
In the recent versions of matplotlib (not sure exactly when this appeared in the 3.3, 3.4 series) if you use a log color scaling with
imshow
and if your data range is very large you can get some unexpected behavior including crashes. This arises from some internal re-scaling thatimshow
does, resulting in rounding error when your max/min data range span many orders of magnitude. If your data also includes zeros, this can lead to the the color scale min being set to 0, which errors for log scaling, which is the source of the error in yt's issue #2890.The current yt fix introduced by PR #3161 is to switch to symlog scaling if you have 0s and a data range greater than 15 orders of magnitude. As the fix in #3161 is not ideal, it should be eventually removed as the fixes get merged upstream. Note that the upstream fix introduces a new boolean keyword argument,
interp_postrgba
, that yt would need to pass to its calls toimshow
, likely with an initial matplotlib version check for some period of time (I believe these changes would be implemented inyt.visualization.base_plot_types.ImagePlotMPL._init_image
).matplotlib links for tracking:
The text was updated successfully, but these errors were encountered: