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

Correcting normalization #49

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 5 additions & 11 deletions meshplot/Viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions meshplot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down