Make colour injecting not the default and put in better safegaurds around injecting the cmap
This commit is contained in:
+1
-1
@@ -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 = [
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user