-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Allow more than 2 colormaps again #493
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1518,33 +1518,32 @@ def _map_face2color(face, colormap, vmin, vmax): | |
| "and vmax. The vmin value cannot be " | ||
| "bigger than or equal to the value " | ||
| "of vmax.") | ||
| # find the normalized distance t of a triangle face between vmin and | ||
| #vmax where the distance is normalized between 0 and 1 | ||
| t = (face - vmin) / float((vmax - vmin)) | ||
|
|
||
| if len(colormap) <= 1: | ||
| t_color = colormap[0] | ||
| color = FigureFactory._convert_to_RGB_255(t_color) | ||
| color = FigureFactory._label_rgb(color) | ||
|
|
||
| if len(colormap) == 1: | ||
| # color each triangle face with the same color in colormap | ||
| face_color = colormap[0] | ||
| face_color = FigureFactory._convert_to_RGB_255(face_color) | ||
| face_color = FigureFactory._label_rgb(face_color) | ||
| else: | ||
| # account for colormaps with more than one color | ||
| incr = 1./(len(colormap) - 1) | ||
| low_color_index = int(t/incr) | ||
| # find the normalized distance t of a triangle face between vmin | ||
| # and vmax where the distance is normalized between 0 and 1 | ||
| t = (face - vmin) / float((vmax - vmin)) | ||
| low_color_index = int(t / (1./(len(colormap) - 1))) | ||
|
||
|
|
||
| if t == 1: | ||
| t_color = colormap[low_color_index] | ||
| color = FigureFactory._convert_to_RGB_255(t_color) | ||
| color = FigureFactory._label_rgb(color) | ||
| face_color = colormap[low_color_index] | ||
| face_color = FigureFactory._convert_to_RGB_255(face_color) | ||
| face_color = FigureFactory._label_rgb(face_color) | ||
|
|
||
| else: | ||
| t_color = FigureFactory._find_intermediate_color( | ||
| face_color = FigureFactory._find_intermediate_color( | ||
| colormap[low_color_index], | ||
| colormap[low_color_index + 1], | ||
| (t - low_color_index * incr) / incr) | ||
| color = FigureFactory._convert_to_RGB_255(t_color) | ||
| color = FigureFactory._label_rgb(color) | ||
| t * (len(colormap) - 1) - low_color_index) | ||
| face_color = FigureFactory._convert_to_RGB_255(face_color) | ||
| face_color = FigureFactory._label_rgb(face_color) | ||
|
|
||
| return color | ||
| return face_color | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💥 so much more readable! thanks! |
||
|
|
||
| @staticmethod | ||
| def _trisurf(x, y, z, simplices, colormap=None, color_func=None, | ||
|
|
||