diff --git a/meshplot/Viewer.py b/meshplot/Viewer.py index d9ab8ae..82e8942 100644 --- a/meshplot/Viewer.py +++ b/meshplot/Viewer.py @@ -131,18 +131,14 @@ def __get_colors(self, v, f, c, sh): colors[:, 1] = 0.874 colors[:, 2] = 0.0 elif type(c) == np.ndarray and c.size == f.shape[0]: # Function values for faces - normalize = sh["normalize"][0] != None and sh["normalize"][1] != None - cc = get_colors(c, sh["colormap"], normalize=normalize, - vmin=sh["normalize"][0], vmax=sh["normalize"][1]) + cc = get_colors(c, sh["colormap"], vmin=sh["normalize"][0], vmax=sh["normalize"][1]) #print(cc.shape) colors = np.hstack([cc, cc, cc]).reshape((-1, 3)) coloring = "FaceColors" - #print("Face function values") + print("Face function values") elif type(c) == np.ndarray and c.size == v.shape[0]: # Function values for vertices - normalize = sh["normalize"][0] != None and sh["normalize"][1] != None - colors = get_colors(c, sh["colormap"], normalize=normalize, - vmin=sh["normalize"][0], vmax=sh["normalize"][1]) - #print("Vertex function values") + colors = get_colors(c, sh["colormap"], vmin=sh["normalize"][0], vmax=sh["normalize"][1]) + print("Vertex function values") else: colors = np.ones_like(v) colors[:, 0] = 1.0 @@ -167,9 +163,7 @@ def __get_point_colors(self, v, c, sh): elif type(c) == np.ndarray and len(c.shape) == 2 and c.shape[1] == 3 and c.shape[0] == v.shape[0]: # Point color colors = c.astype("float32", copy=False) elif type(c) == np.ndarray and c.size == v.shape[0]: # Function color - normalize = sh["normalize"][0] != None and sh["normalize"][1] != None - colors = get_colors(c, sh["colormap"], normalize=normalize, - vmin=sh["normalize"][0], vmax=sh["normalize"][1]) + colors = get_colors(c, sh["colormap"], vmin=sh["normalize"][0], vmax=sh["normalize"][1]) colors = colors.astype("float32", copy=False) #print("Vertex function values") else: diff --git a/meshplot/utils.py b/meshplot/utils.py index 91867f2..03682e6 100644 --- a/meshplot/utils.py +++ b/meshplot/utils.py @@ -3,9 +3,9 @@ import matplotlib as mpl # Helper functions -def get_colors(inp, colormap="viridis", normalize=True, vmin=None, vmax=None): +def get_colors(inp, colormap="viridis", vmin=None, vmax=None): colormap = plt.cm.get_cmap(colormap) - if normalize: + if vmin==None or vmax==None: vmin=np.min(inp) vmax=np.max(inp)