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

Merge develop into master #54

Merged
merged 6 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ Versioning <http://semver.org/>`__. The changelog format is inspired by

`Unreleased <https://github.com/smtg-ucl/galore/compare/0.9.0...HEAD>`__
-------------------------------------------------------------------------
- Deal with matplotlib compatibility issues (@ajjackson)

- 3.6 deprecation/rename of seaborn-colorblind
- Use public API to get line colour more robustly

- Deal with scipy deprecation of polyval (@kavanase)


`[0.9.0] <https://github.com/smtg-ucl/galore/compare/0.8.0...0.9.0>`__ - 2023-08-14
-----------------------------------------------------------------------------------
Expand Down
5 changes: 3 additions & 2 deletions galore/cli/galore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
9 changes: 4 additions & 5 deletions galore/cli/galore_plot_cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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.""")
Expand All @@ -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()
Expand Down
12 changes: 12 additions & 0 deletions galore/cli/utils.py
Original file line number Diff line number Diff line change
@@ -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__) < Version("3.6"):
return "seaborn-colorblind"

return "seaborn-v0_8-colorblind"
3 changes: 1 addition & 2 deletions galore/cross_sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@


import sqlite3
from scipy import polyval
from numpy import fromstring as np_fromstr
from numpy import exp, log
from numpy import exp, log, polyval


def get_cross_sections(weighting, elements=None):
Expand Down
13 changes: 6 additions & 7 deletions galore/plot.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -158,15 +158,14 @@ def plot_pdos(pdos_data, ax=None, total=True, show_orbitals=True, offset=0., fli
max_y = max(max_y, max(el_data[orbital]))

if show_orbitals:
color = next(ax._get_lines.prop_cycler)['color'] # get color to ensure
# matching fill
label = (None if max(el_data[orbital]) < legend_cutoff * tmax
else "{0}: {1}".format(element, orbital))
ax.plot(x_data, el_data[orbital], color=color, label=label,
marker='', linestyle=next(linecycler))
(line2d, ) = ax.plot(x_data, el_data[orbital], label=label,
marker='', linestyle=next(linecycler))

if fill:
ax.fill_between(x_data, el_data[orbital], color=color, alpha=alpha)
ax.fill_between(x_data, el_data[orbital],
color=line2d.get_color(), alpha=alpha)

if total:
max_y = max(tdos)
Expand Down
Loading