Last active
July 25, 2017 18:04
-
-
Save danzimmerman/c9cb47ca01212e2823f9586ab3faa6ec to your computer and use it in GitHub Desktop.
Prints an Abaqus python console command to add a named matplotlib colormap to a running Abaqus session. Tested with Abaqus/Viewer 6.13-4.
This file contains 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
#Prints out an Abaqus console command to add a matplotlib colormap to a running Abaqus Viewer session | |
#Tested with Abaqus/Viewer 6.13-4 | |
#change COLORMAP_NAME for different options | |
import matplotlib.cm as cm | |
COLORMAP_NAME = 'magma_r' | |
chosen_cmap = cm.get_cmap(COLORMAP_NAME) | |
cols = chosen_cmap(xrange(0,255,16)) | |
clist = [] | |
for col in cols: | |
r = '{0:x}'.format((col[0]*255).astype(int)).zfill(2) | |
g = '{0:x}'.format((col[1]*255).astype(int)).zfill(2) | |
b = '{0:x}'.format((col[2]*255).astype(int)).zfill(2) | |
colstr = '#{0}{1}{2}'.format(r,g,b) | |
clist.append(colstr) | |
cstr = repr(tuple(clist)) | |
abq_cmd = 'session.Spectrum(name=\'{0}\',colors={1})'.format(COLORMAP_NAME,cstr) | |
print(abq_cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Intent
Quickly add matplotlib built-in color maps for field output visualization in Abaqus/Viewer. Intended to copy and paste into the console, but easily modified for odb visualization scripts.
My particular interest was the use of perceptually uniform colormaps for field value contour plots. The reversed versions allow better visualization of the 3D shape of the part for positive-definite quantities.
Examples
'viridis' reversed:
![image](https://user-images.githubusercontent.com/4365714/28582134-56f4c422-7132-11e7-97e2-24c0126d9189.png)
![image](https://user-images.githubusercontent.com/4365714/28582153-643a35ae-7132-11e7-8966-c309a01460ee.png)
'magma' reversed:
Running the code prints a
session.Spectrum()
command like:session.Spectrum(name='magma_r',colors=('#fbfcbf', '#fddfa1', '#fec286', '#fda470', '#fb8660', '#f4685b', '#e55063', '#ce4070', '#b53679', '#9a2d7f', '#812581', '#681b80', '#4f117b', '#341068', '#1b1044', '#09071f'))