Created
June 25, 2012 23:54
-
-
Save stefanv/2992176 to your computer and use it in GitHub Desktop.
paraview colormaps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _para1 = {'red': ((0.0, 0.019390722, 0.019390722), (0.125, 0.355334722, | |
| 0.355334722), (0.25, 0.565570631, 0.565570631), (0.375, | |
| 0.76583663, 0.76583663), (0.5, 0.966006412, 0.966006412), | |
| (0.625, 0.953403586, 0.953403586), (0.75, 0.906621393, | |
| 0.906621393), (0.875, 0.831556904, 0.831556904), (1.0, | |
| 0.732691891, 0.732691891)), | |
| 'green': ((0.0, 0.390501895, 0.390501895), (0.125, 0.524474908, | |
| 0.524474908), (0.25, 0.665714642, 0.665714642), (0.375, | |
| 0.813150205, 0.813150205), (0.5, 0.96603773, 0.96603773), | |
| (0.625, 0.766601281, 0.766601281), (0.75, 0.568733213, | |
| 0.568733213), (0.875, 0.365112385, 0.365112385), (1.0, | |
| 0.098811709, 0.098811709)), | |
| 'blue': ((0.0, 0.586262521, 0.586262521), (0.125, 0.679588113, | |
| 0.679588113), (0.25, 0.773984466, 0.773984466), (0.375, | |
| 0.869436965, 0.869436965), (0.5, 0.965934958, 0.965934958), | |
| (0.625, 0.713328364, 0.713328364), (0.75, 0.473912925, | |
| 0.473912925), (0.875, 0.247843798, 0.247843798), (1.0, | |
| 0.00679232, 0.00679232)) | |
| } | |
| _para2 = {'red': ((0.0, 0.07514311, 0.07514311), (0.03125, 0.247872569, | |
| 0.247872569), (0.0625, 0.339526309, 0.339526309), (0.09375, | |
| 0.409505078, 0.409505078), (0.125, 0.468487184, 0.468487184), | |
| (0.15625, 0.520796675, 0.520796675), (0.1875, 0.568724526, | |
| 0.568724526), (0.21875, 0.613686735, 0.613686735), (0.25, | |
| 0.656658579, 0.656658579), (0.28125, 0.698372844, | |
| 0.698372844), (0.3125, 0.739424025, 0.739424025), (0.34375, | |
| 0.780330104, 0.780330104), (0.375, 0.821573924, 0.821573924), | |
| (0.40625, 0.863634967, 0.863634967), (0.4375, 0.907017747, | |
| 0.907017747), (0.46875, 0.936129275, 0.936129275), (0.5, | |
| 0.943467973, 0.943467973), (0.53125, 0.990146732, | |
| 0.990146732), (0.5625, 1.0, 1.0), (0.59375, 1.0, 1.0), | |
| (0.625, 1.0, 1.0), (0.65625, 1.0, 1.0), (0.6875, 1.0, 1.0), | |
| (0.71875, 1.0, 1.0), (0.75, 1.0, 1.0), (0.78125, 1.0, 1.0), | |
| (0.8125, 1.0, 1.0), (0.84375, 1.0, 1.0), (0.875, 1.0, 1.0), | |
| (0.90625, 1.0, 1.0), (0.9375, 1.0, 1.0), (0.96875, | |
| 0.961891484, 0.961891484), (1.0, 0.916482116, 0.916482116)), | |
| 'green': ((0.0, 0.468049805, 0.468049805), (0.03125, 0.498782363, | |
| 0.498782363), (0.0625, 0.528909511, 0.528909511), (0.09375, | |
| 0.558608486, 0.558608486), (0.125, 0.588057293, | |
| 0.588057293), (0.15625, 0.617435078, 0.617435078), (0.1875, | |
| 0.646924167, 0.646924167), (0.21875, 0.676713218, | |
| 0.676713218), (0.25, 0.707001303, 0.707001303), (0.28125, | |
| 0.738002964, 0.738002964), (0.3125, 0.769954435, | |
| 0.769954435), (0.34375, 0.803121429, 0.803121429), (0.375, | |
| 0.837809045, 0.837809045), (0.40625, 0.874374691, | |
| 0.874374691), (0.4375, 0.913245283, 0.913245283), (0.46875, | |
| 0.938743558, 0.938743558), (0.5, 0.943498599, 0.943498599), | |
| (0.53125, 0.928791426, 0.928791426), (0.5625, 0.88332677, | |
| 0.88332677), (0.59375, 0.833985467, 0.833985467), (0.625, | |
| 0.788626485, 0.788626485), (0.65625, 0.746206642, | |
| 0.746206642), (0.6875, 0.70590052, 0.70590052), (0.71875, | |
| 0.667019783, 0.667019783), (0.75, 0.6289553, 0.6289553), | |
| (0.78125, 0.591130233, 0.591130233), (0.8125, 0.552955184, | |
| 0.552955184), (0.84375, 0.513776083, 0.513776083), (0.875, | |
| 0.472800903, 0.472800903), (0.90625, 0.428977855, | |
| 0.428977855), (0.9375, 0.380759558, 0.380759558), (0.96875, | |
| 0.313155629, 0.313155629), (1.0, 0.236630659, | |
| 0.236630659)), | |
| 'blue': ((0.0, 1.0, 1.0), (0.03125, 1.0, 1.0), (0.0625, 1.0, 1.0), | |
| (0.09375, 1.0, 1.0), (0.125, 1.0, 1.0), (0.15625, 1.0, 1.0), | |
| (0.1875, 1.0, 1.0), (0.21875, 1.0, 1.0), (0.25, 1.0, 1.0), | |
| (0.28125, 1.0, 1.0), (0.3125, 1.0, 1.0), (0.34375, 1.0, | |
| 1.0), (0.375, 1.0, 1.0), (0.40625, 1.0, 1.0), (0.4375, 1.0, | |
| 1.0), (0.46875, 0.983038586, 0.983038586), (0.5, | |
| 0.943398095, 0.943398095), (0.53125, 0.917447482, | |
| 0.917447482), (0.5625, 0.861943246, 0.861943246), (0.59375, | |
| 0.803839606, 0.803839606), (0.625, 0.750707739, | |
| 0.750707739), (0.65625, 0.701389973, 0.701389973), (0.6875, | |
| 0.654994046, 0.654994046), (0.71875, 0.610806959, | |
| 0.610806959), (0.75, 0.568237474, 0.568237474), (0.78125, | |
| 0.526775617, 0.526775617), (0.8125, 0.485962266, | |
| 0.485962266), (0.84375, 0.445364274, 0.445364274), (0.875, | |
| 0.404551679, 0.404551679), (0.90625, 0.363073592, | |
| 0.363073592), (0.9375, 0.320428137, 0.320428137), (0.96875, | |
| 0.265499262, 0.265499262), (1.0, 0.209939162, 0.209939162)) | |
| } | |
| if __name__ == "__main__": | |
| from matplotlib import colors | |
| para1 = colors.LinearSegmentedColormap('para1', _para1, 256) | |
| para2 = colors.LinearSegmentedColormap('para2', _para2, 256) | |
| ## from skimage import data | |
| ## img = data.camera() | |
| ## import matplotlib.pyplot as plt | |
| ## f, (ax0, ax1) = plt.subplots(1, 2) | |
| ## ax0.imshow(img, cmap=para1) | |
| ## ax1.imshow(img, cmap=para2) | |
| ## plt.show() | |
| # Modified from the Mayavi example: | |
| # | |
| # Author: Gael Varoquaux <gael.varoquaux@normalesup.org> | |
| # Copyright (c) 2007, Enthought, Inc. | |
| # License: BSD Style. | |
| from numpy import cos, sin, pi, sqrt, mgrid, linspace | |
| from mayavi import mlab | |
| mlab.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1)) | |
| u, v = mgrid[-0.035:pi:0.01, -0.035:pi:0.01] | |
| X = 2/3.* (cos(u)* cos(2*v) | |
| + sqrt(2)* sin(u)* cos(v))* cos(u) / (sqrt(2) - sin(2*u)* sin(3*v)) | |
| Y = 2/3.* (cos(u)* sin(2*v) - sqrt(2)* sin(u)* sin(v))* cos(u) / (sqrt(2) | |
| - sin(2*u)* sin(3*v)) | |
| Z = -sqrt(2)* cos(u)* cos(u) / (sqrt(2) - sin(2*u)* sin(3*v)) | |
| S = sin(u) | |
| mesh = mlab.mesh(X, Y, Z, scalars=S, colormap='YlGnBu') | |
| cm = para2(linspace(0, 1, 256), bytes=True) | |
| mesh.module_manager.scalar_lut_manager.lut.table = cm | |
| mlab.draw() | |
| mlab.view(.0, -5.0, 4) | |
| mlab.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment