Skip to content

Commit

Permalink
DEP Fix MPL colorbar norm deprecation (#430)
Browse files Browse the repository at this point in the history
Closes #414 by adding a mesh detector plot
  • Loading branch information
drewejohnson authored Dec 22, 2020
1 parent 628f81e commit 8bb05e7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion serpentTools/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def cartMeshPlot(data, xticks=None, yticks=None, ax=None, cmap=None,
else:
X, Y = meshgrid(xticks, yticks)
mappable = ax.pcolormesh(X, Y, data, cmap=cmap, norm=norm, **kwargs)
addColorbar(ax, mappable, norm, cbarLabel)
addColorbar(ax, mappable, cbarLabel)

return ax

Expand Down
2 changes: 1 addition & 1 deletion serpentTools/utils/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def addColorbar(ax, mappable, norm=None, cbarLabel=None):
The colorbar that was added
"""
cbar = pyplot.colorbar(mappable, ax=ax, norm=norm)
cbar = pyplot.colorbar(mappable, ax=ax)
if cbarLabel:
cbar.ax.set_ylabel(cbarLabel)
return cbar
Binary file added tests/plots/result_images/testBwrMeshPlot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion tests/plots/test_detectors.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
from . import compare_or_update_plot
import pytest
from serpentTools.data import readDataFile

from . import compare_or_update_plot


@compare_or_update_plot
def testSpectrumPlot():
reader = readDataFile("bwr_det0.m")
reader["spectrum"].spectrumPlot()


@compare_or_update_plot
def testBwrMeshPlot():
reader = readDataFile("bwr_det0.m")
# Ensure that fix for #414 in in: matplotlib colorbar norm
with pytest.warns(None) as record:
reader["xymesh"].meshPlot(fixed={"energy": 0})
assert len(record) == 0

0 comments on commit 8bb05e7

Please sign in to comment.