diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index e5f2266..47e4e1a 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -7,6 +7,8 @@ Versioning `__. The changelog format is inspired by
`Unreleased `__
-------------------------------------------------------------------------
+- Deal with matplotlib 3.6 deprecation/rename of seaborn-colorblind (@ajjackson)
+
`[0.9.0] `__ - 2023-08-14
-----------------------------------------------------------------------------------
diff --git a/galore/cli/galore.py b/galore/cli/galore.py
index c2cdcca..d1efe21 100755
--- a/galore/cli/galore.py
+++ b/galore/cli/galore.py
@@ -29,6 +29,7 @@
import numpy as np
import galore
+from galore.cli.utils import get_default_style
import galore.formats
import galore.plot
from galore import auto_limits
@@ -287,9 +288,9 @@ def get_parser():
parser.add_argument(
'--ymax', type=float, default=None, help='Maximum y axis value')
parser.add_argument(
- '--style', type=str, nargs='+', default=['seaborn-colorblind'],
+ '--style', type=str, nargs='+', default=get_default_style(),
help='Plotting style: a sequence of matplotlib styles and paths to '
- 'style files. The default palette is called "seaborn-colorblind".'
+ 'style files.'
)
parser.add_argument(
'--overlay', type=str, default=None, help='Data file for overlay')
diff --git a/galore/cli/galore_plot_cs.py b/galore/cli/galore_plot_cs.py
index 4e2cca1..a835eba 100755
--- a/galore/cli/galore_plot_cs.py
+++ b/galore/cli/galore_plot_cs.py
@@ -25,8 +25,8 @@
import logging
import numpy as np
from matplotlib import pyplot as plt
-plt.style.use('seaborn-colorblind')
+from galore.cli import get_default_style
from galore.cross_sections import get_cross_sections_scofield
@@ -52,9 +52,9 @@ def get_parser():
parser.add_argument('--fontsize', type=int, default=12,
help="Font size in pt")
parser.add_argument(
- '--style', type=str, nargs='+', default=['seaborn-colorblind'],
+ '--style', type=str, nargs='+', default=get_default_style(),
help='Plotting style: a sequence of matplotlib styles and paths to '
- 'style files. The default palette is called "seaborn-colorblind".'
+ 'style files.'
)
parser.add_argument('elements', type=str, nargs='+', help="""
Space-separated symbols for elements in material.""")
@@ -67,8 +67,7 @@ def run(elements, emin=1, emax=10, megabarn=False, size=None, output=None,
energies = np.linspace(emin, emax, 200)
cross_sections = get_cross_sections_scofield(energies, elements)
- if style is not None:
- plt.style.use(style)
+ plt.style.use(style)
if size is None:
fig = plt.figure()
diff --git a/galore/cli/utils.py b/galore/cli/utils.py
new file mode 100644
index 0000000..4628296
--- /dev/null
+++ b/galore/cli/utils.py
@@ -0,0 +1,12 @@
+"""Utility functions used by command-line tools"""
+
+import matplotlib
+from packaging.version import Version
+
+def get_default_style() -> str:
+ """Get appropriate name for seaborn-colorblind, depending on MPL version"""
+
+ if Version(matplotlib) < Version("3.6"):
+ return "seaborn-colorblind"
+
+ return "seaborn-v0_8-colorblind"
diff --git a/galore/plot.py b/galore/plot.py
index 0123e90..cba2b28 100644
--- a/galore/plot.py
+++ b/galore/plot.py
@@ -1,11 +1,11 @@
"""Plotting routines with Matplotlib"""
from collections import defaultdict
-from os.path import basename as path_basename
from itertools import cycle
+from os.path import basename as path_basename
import logging
-import numpy as np
from matplotlib import pyplot as plt
+import numpy as np
from galore import auto_limits
import galore.formats