Commit 3e11c5fb authored by Martin Reinecke's avatar Martin Reinecke
Browse files

compactigy

parent 850b5070
Pipeline #18155 passed with stage
in 5 minutes and 30 seconds
......@@ -72,14 +72,10 @@ def _makeplot(name):
def _limit_xy(**kwargs):
import matplotlib.pyplot as plt
x1, x2, y1, y2 = plt.axis()
if (kwargs.get("xmin")) is not None:
x1 = kwargs.get("xmin")
if (kwargs.get("xmax")) is not None:
x2 = kwargs.get("xmax")
if (kwargs.get("ymin")) is not None:
y1 = kwargs.get("ymin")
if (kwargs.get("ymax")) is not None:
y2 = kwargs.get("ymax")
x1 = _get_kw("xmin", x1, **kwargs)
x2 = _get_kw("xmax", x2, **kwargs)
y1 = _get_kw("ymin", y1, **kwargs)
y2 = _get_kw("xmax", y2, **kwargs)
plt.axis((x1, x2, y1, y2))
......@@ -92,126 +88,52 @@ def _register_cmaps():
from matplotlib.colors import LinearSegmentedColormap
import matplotlib.pyplot as plt
planckcmap = {'red': ((0.0, 0.0, 0.0),
(0.4, 0.0, 0.0),
(0.5, 1.0, 1.0),
(0.7, 1.0, 1.0),
(0.8, 0.83, 0.83),
(0.9, 0.67, 0.67),
(1.0, 0.5, 0.5)),
'green': ((0.0, 0.0, 0.0),
(0.2, 0.0, 0.0),
(0.3, 0.3, 0.3),
(0.4, 0.7, 0.7),
(0.5, 1.0, 1.0),
(0.6, 0.7, 0.7),
(0.7, 0.3, 0.3),
(0.8, 0.0, 0.0),
(1.0, 0.0, 0.0)),
'blue': ((0.0, 0.5, 0.5),
(0.1, 0.67, 0.67),
(0.2, 0.83, 0.83),
(0.3, 1.0, 1.0),
(0.5, 1.0, 1.0),
(0.6, 0.0, 0.0),
(1.0, 0.0, 0.0))}
he_cmap = {'red': ((0.0, 0.0, 0.0),
(0.167, 0.0, 0.0),
(0.333, 0.5, 0.5),
(0.5, 1.0, 1.0),
(1.0, 1.0, 1.0)),
'green': ((0.0, 0.0, 0.0),
(0.5, 0.0, 0.0),
(0.667, 0.5, 0.5),
(0.833, 1.0, 1.0),
(1.0, 1.0, 1.0)),
'blue': ((0.0, 0.0, 0.0),
(0.167, 1.0, 1.0),
(0.333, 0.5, 0.5),
(0.5, 0.0, 0.0),
(1.0, 1.0, 1.0))}
fd_cmap = {'red': ((0.0, 0.35, 0.35),
(0.1, 0.4, 0.4),
(0.2, 0.25, 0.25),
(0.41, 0.47, 0.47),
(0.5, 0.8, 0.8),
(0.56, 0.96, 0.96),
(0.59, 1.0, 1.0),
(0.74, 0.8, 0.8),
(0.8, 0.8, 0.8),
(0.9, 0.5, 0.5),
(1.0, 0.4, 0.4)),
'green': ((0.0, 0.0, 0.0),
(0.2, 0.0, 0.0),
(0.362, 0.88, 0.88),
(0.5, 1.0, 1.0),
(0.638, 0.88, 0.88),
(0.8, 0.25, 0.25),
(0.9, 0.3, 0.3),
(1.0, 0.2, 0.2)),
'blue': ((0.0, 0.35, 0.35),
(0.1, 0.4, 0.4),
(0.2, 0.8, 0.8),
(0.26, 0.8, 0.8),
(0.41, 1.0, 1.0),
(0.44, 0.96, 0.96),
(0.5, 0.8, 0.8),
(0.59, 0.47, 0.47),
(0.8, 0.0, 0.0),
(1.0, 0.0, 0.0))}
fdu_cmap = {'red': ((0.0, 1.0, 1.0),
(0.1, 0.8, 0.8),
(0.2, 0.65, 0.65),
(0.41, 0.6, 0.6),
(0.5, 0.7, 0.7),
(0.56, 0.96, 0.96),
(0.59, 1.0, 1.0),
(0.74, 0.8, 0.8),
(0.8, 0.8, 0.8),
(0.9, 0.5, 0.5),
(1.0, 0.4, 0.4)),
'green': ((0.0, 0.9, 0.9),
(0.2, 0.65, 0.65),
(0.362, 0.95, 0.95),
(0.5, 1.0, 1.0),
(0.638, 0.88, 0.88),
(0.8, 0.25, 0.25),
(0.9, 0.3, 0.3),
(1.0, 0.2, 0.2)),
'blue': ((0.0, 1.0, 1.0),
(0.1, 0.8, 0.8),
(0.2, 1.0, 1.0),
(0.41, 1.0, 1.0),
(0.44, 0.96, 0.96),
(0.5, 0.7, 0.7),
(0.59, 0.42, 0.42),
(0.8, 0.0, 0.0),
(1.0, 0.0, 0.0))}
pm_cmap = {'red': ((0.0, 1.0, 1.0),
(0.1, 0.96, 0.96),
(0.2, 0.84, 0.84),
(0.3, 0.64, 0.64),
(0.4, 0.36, 0.36),
(0.5, 0.0, 0.0),
(1.0, 0.0, 0.0)),
'green': ((0.0, 0.5, 0.5),
(0.1, 0.32, 0.32),
(0.2, 0.18, 0.18),
(0.3, 0.08, 0.08),
(0.4, 0.02, 0.02),
(0.5, 0.0, 0.0),
(0.6, 0.02, 0.02),
(0.7, 0.08, 0.08),
(0.8, 0.18, 0.18),
(0.9, 0.32, 0.32),
(1.0, 0.5, 0.5)),
'blue': ((0.0, 0.0, 0.0),
(0.5, 0.0, 0.0),
(0.6, 0.36, 0.36),
(0.7, 0.64, 0.64),
(0.8, 0.84, 0.84),
(0.9, 0.96, 0.96),
(1.0, 1.0, 1.0))}
planckcmap = {'red': ((0., 0., 0.), (.4, 0., 0.), (.5, 1., 1.),
(.7, 1., 1.), (.8, .83, .83), (.9, .67, .67),
(1., .5, .5)),
'green': ((0., 0., 0.), (.2, 0., 0.), (.3, .3, .3),
(.4, .7, .7), (.5, 1., 1.), (.6, .7, .7),
(.7, .3, .3), (.8, 0., 0.), (1., 0., 0.)),
'blue': ((0., .5, .5), (.1, .67, .67), (.2, .83, .83),
(.3, 1., 1.), (.5, 1., 1.), (.6, 0., 0.),
(1., 0., 0.))}
he_cmap = {'red': ((0., 0., 0.), (.167, 0., 0.), (.333, .5, .5),
(.5, 1., 1.), (1., 1., 1.)),
'green': ((0., 0., 0.), (.5, 0., 0.), (.667, .5, .5),
(.833, 1., 1.), (1., 1., 1.)),
'blue': ((0., 0., 0.), (.167, 1., 1.), (.333, .5, .5),
(.5, 0., 0.), (1., 1., 1.))}
fd_cmap = {'red': ((0., .35, .35), (.1, .4, .4), (.2, .25, .25),
(.41, .47, .47), (.5, .8, .8), (.56, .96, .96),
(.59, 1., 1.), (.74, .8, .8), (.8, .8, .8),
(.9, .5, .5), (1., .4, .4)),
'green': ((0., 0., 0.), (.2, 0., 0.), (.362, .88, .88),
(.5, 1., 1.), (.638, .88, .88), (.8, .25, .25),
(.9, .3, .3), (1., .2, .2)),
'blue': ((0., .35, .35), (.1, .4, .4), (.2, .8, .8),
(.26, .8, .8), (.41, 1., 1.), (.44, .96, .96),
(.5, .8, .8), (.59, .47, .47), (.8, 0., 0.),
(1., 0., 0.))}
fdu_cmap = {'red': ((0., 1., 1.), (0.1, .8, .8), (.2, .65, .65),
(.41, .6, .6), (.5, .7, .7), (.56, .96, .96),
(.59, 1., 1.), (.74, .8, .8), (.8, .8, .8),
(.9, .5, .5), (1., .4, .4)),
'green': ((0., .9, .9), (.362, .95, .95), (.5, 1., 1.),
(.638, .88, .88), (.8, .25, .25), (.9, .3, .3),
(1., .2, .2)),
'blue': ((0., 1., 1.), (.1, .8, .8), (.2, 1., 1.),
(.41, 1., 1.), (.44, .96, .96), (.5, .7, .7),
(.59, .42, .42), (.8, 0., 0.), (1., 0., 0.))}
pm_cmap = {'red': ((0., 1., 1.), (.1, .96, .96), (.2, .84, .84),
(.3, .64, .64), (.4, .36, .36), (.5, 0., 0.),
(1., 0., 0.)),
'green': ((0., .5, .5), (.1, .32, .32), (.2, .18, .18),
(.3, .8, .8), (.4, .2, .2), (.5, 0., 0.),
(.6, .2, .2), (.7, .8, .8), (.8, .18, .18),
(.9, .32, .32), (1., .5, .5)),
'blue': ((0., 0., 0.), (.5, 0., 0.), (.6, .36, .36),
(.7, .64, .64), (.8, .84, .84), (.9, .96, .96),
(1., 1., 1.))}
plt.register_cmap(cmap=LinearSegmentedColormap("Planck-like", planckcmap))
plt.register_cmap(cmap=LinearSegmentedColormap("High Energy", he_cmap))
......@@ -221,6 +143,12 @@ def _register_cmaps():
plt.register_cmap(cmap=LinearSegmentedColormap("Plus Minus", pm_cmap))
def _get_kw(kwname, kwdefault=None, **kwargs):
if kwargs.get(kwname) is not None:
return kwargs.get(kwname)
return kwdefault
def plot(f, **kwargs):
import matplotlib.pyplot as plt
_register_cmaps()
......@@ -233,22 +161,13 @@ def plot(f, **kwargs):
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
xsize, ysize = 6, 6
if kwargs.get("xsize") is not None:
xsize = kwargs.get("xsize")
if kwargs.get("ysize") is not None:
ysize = kwargs.get("ysize")
xsize = _get_kw("xsize", 6, **kwargs)
ysize = _get_kw("ysize", 6, **kwargs)
fig.set_size_inches(xsize, ysize)
if kwargs.get("title") is not None:
ax.set_title(kwargs.get("title"))
if kwargs.get("xlabel") is not None:
ax.set_xlabel(kwargs.get("xlabel"))
if kwargs.get("ylabel") is not None:
ax.set_ylabel(kwargs.get("ylabel"))
cmap = plt.rcParams['image.cmap']
if kwargs.get("colormap") is not None:
cmap = kwargs.get("colormap")
ax.set_title(_get_kw("title", "", **kwargs))
ax.set_xlabel(_get_kw("xlabel", "", **kwargs))
ax.set_ylabel(_get_kw("ylabel", "", **kwargs))
cmap = _get_kw("colormap", plt.rcParams['image.cmap'], **kwargs)
if isinstance(dom, RGSpace):
if len(dom.shape) == 1:
npoints = dom.shape[0]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment