Skip to content

Commit a08fdbe

Browse files
committed
tweak viscm layout + teach save files to use viscm proper to display themselves
1 parent f3c88a4 commit a08fdbe

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

pycam02ucs/cm/viscm.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ def _vis_axes():
172172

173173
'image0': grid[0:3, 2],
174174
'image0-cb': grid[0:3, 3],
175-
'image1': grid[3:6, 2],
176-
'image1-cb': grid[3:6, 3],
177-
'image2': grid[6:9, 2],
178-
'image2-cb': grid[6:9, 3],
175+
'image1': grid[3:7, 2],
176+
'image1-cb': grid[3:7, 3],
177+
'image2': grid[7:, 2],
178+
'image2-cb': grid[7:, 3],
179179
}
180180

181181
axes = {key: plt.subplot(value) for (key, value) in axes.items()}
@@ -310,7 +310,7 @@ def toggle(*args):
310310
"vmin": 0})
311311

312312
images.append(np.loadtxt(example_dir
313-
+ "st-helens_before-modified.txt.gz"))
313+
+ "st-helens_before-modified.txt.gz").T)
314314
image_args.append({})
315315

316316
# Adapted from http://matplotlib.org/mpl_examples/images_contours_and_fields/pcolormesh_levels.py
@@ -536,15 +536,20 @@ def save_colormap(self, event):
536536
537537
cm_data = {array_list}
538538
539-
test_cm = LinearSegmentedColormap.from_list('test_cm', cm_data)
539+
test_cm = LinearSegmentedColormap.from_list(__file__, cm_data)
540540
541541
542542
if __name__ == "__main__":
543543
import matplotlib.pyplot as plt
544544
import numpy as np
545545
546-
plt.imshow(np.linspace(0, 100, 256)[None, :], aspect='auto',
547-
cmap=test_cm)
546+
try:
547+
from pycam02ucs.cm.viscm import viscm
548+
viscm(test_cm)
549+
except ImportError:
550+
print("pycam02ucs not found, falling back on simple display")
551+
plt.imshow(np.linspace(0, 100, 256)[None, :], aspect='auto',
552+
cmap=test_cm)
548553
plt.show()
549554
''')
550555

0 commit comments

Comments
 (0)