diff --git a/pyproject.toml b/pyproject.toml index b1ad589..641707b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "makegraph" -version = "0.2.0" +version = "0.2.1" description = "A custom python Matplotlib wrapper" readme = "README.md" authors = [ @@ -13,4 +13,4 @@ dependencies = [ [build-system] requires = ["uv_build>=0.10.2,<0.11.0"] -build-backend = "uv_build" +build-backend = "uv_build" \ No newline at end of file diff --git a/src/makegraph/__init__.py b/src/makegraph/__init__.py index be2f544..45c043c 100644 --- a/src/makegraph/__init__.py +++ b/src/makegraph/__init__.py @@ -2,7 +2,7 @@ from .colours import ColourValue, ColourContainer from .uq_colours import UQ_COLOURS_DICT, UQ_COLOURS, add_colours_to_mpl from .makegraph import makeGraph, pltKeyClose -__version__ = "0.2.0" +__version__ = "0.2.1" __all__ = [ "makeGraph", "pltKeyClose", diff --git a/src/makegraph/uq_colours.py b/src/makegraph/uq_colours.py index 2a061c5..1b9a319 100644 --- a/src/makegraph/uq_colours.py +++ b/src/makegraph/uq_colours.py @@ -18,8 +18,7 @@ if _MG_INJECT_MPL_COLOURS_ENVIRON_VAR in os.environ: except ValueError: INJECT_COLOURS = False else: - # Default to always injecting colours on load - INJECT_COLOURS = True + INJECT_COLOURS = False # Define the UQ Colours UQ_COLOURS_DICT = { @@ -111,7 +110,11 @@ for i, c in enumerate(uq_colour_map_grad): uq_colour_dict["blue"].append( (offset, c[2], c[2]) ) #Define & register the colour map itself -uq_cmap = mpl_colors.LinearSegmentedColormap('uq', segmentdata=uq_colour_dict) # ty:ignore[invalid-argument-type] +UQ_CMAP_NAME = "uq" +uq_cmap = mpl_colors.LinearSegmentedColormap( + name=UQ_CMAP_NAME, + segmentdata=uq_colour_dict # ty:ignore[invalid-argument-type] +) # Wrap all MPL calls in a function def add_colours_to_mpl(update_cycler: bool = True, once_only: bool = False): @@ -129,7 +132,8 @@ def add_colours_to_mpl(update_cycler: bool = True, once_only: bool = False): plt.rc('axes', prop_cycle=uq_colour_cycler) # Add the colour map to MPL - matplotlib.colormaps.register(uq_cmap) + if UQ_CMAP_NAME not in matplotlib.colormaps: + matplotlib.colormaps.register(uq_cmap) # Set the colour map - Not a very good default so not doing that #plt.set_cmap("uq")