diff --git a/openmc/plotter.py b/openmc/plotter.py index 97ca5f929..aa3825f5e 100644 --- a/openmc/plotter.py +++ b/openmc/plotter.py @@ -59,10 +59,15 @@ def _get_legend_label(this, type): """Gets a label for the element or nuclide or material and reaction plotted""" if isinstance(this, str): if type in openmc.data.DADZ: - z, a, m = openmc.data.zam(this) - da, dz = openmc.data.DADZ[type] - gnds_name = openmc.data.gnds_name(z + dz, a + da, m) - return f'{this} {type} {gnds_name}' + if this in ELEMENT_NAMES: + return f'{this} {type}' + else: # this is a nuclide so the legend can contain more information + z, a, m = openmc.data.zam(this) + da, dz = openmc.data.DADZ[type] + gnds_name = openmc.data.gnds_name(z + dz, a + da, m) + # makes a string with nuclide reaction and new nuclide + # For example "Be9 (n,2n) Be8" + return f'{this} {type} {gnds_name}' return f'{this} {type}' elif this.name == '': return f'Material {this.id} {type}' diff --git a/tests/unit_tests/test_plotter.py b/tests/unit_tests/test_plotter.py index 2c195c5e1..0220cec3e 100644 --- a/tests/unit_tests/test_plotter.py +++ b/tests/unit_tests/test_plotter.py @@ -75,7 +75,7 @@ def test_calculate_cexs_with_materials(test_mat): @pytest.mark.parametrize("this", ["Be", "Be9"]) def test_plot_xs(this): from matplotlib.figure import Figure - assert isinstance(openmc.plot_xs({this: ['total', 'elastic']}), Figure) + assert isinstance(openmc.plot_xs({this: ['total', 'elastic', 16, '(n,2n)']}), Figure) def test_plot_xs_mat(test_mat):