@@ -492,7 +492,7 @@ def save_colormap(self, event):
492
492
import textwrap
493
493
494
494
template = textwrap .dedent ('''
495
- from matplotlib.colors import LinearSegmentedColormap
495
+ from matplotlib.colors import ListedColormap
496
496
from numpy import nan, inf
497
497
498
498
# Used to reconstruct the colormap in pycam02ucs.cm.viscm
@@ -503,27 +503,28 @@ def save_colormap(self, event):
503
503
504
504
cm_data = {array_list}
505
505
506
- test_cm = LinearSegmentedColormap.from_list(__file__, cm_data )
506
+ test_cm = ListedColormap(cm_data, name=__file__ )
507
507
508
508
509
509
if __name__ == "__main__":
510
510
import matplotlib.pyplot as plt
511
511
import numpy as np
512
512
513
513
try:
514
- from pycam02ucs.cm. viscm import viscm
514
+ from viscm import viscm
515
515
viscm(test_cm)
516
516
except ImportError:
517
- print("pycam02ucs not found, falling back on simple display")
517
+ print("viscm not found, falling back on simple display")
518
518
plt.imshow(np.linspace(0, 100, 256)[None, :], aspect='auto',
519
519
cmap=test_cm)
520
520
plt.show()
521
521
''' )
522
522
523
523
rgb , _ = self .cmap_model .get_sRGB (num = 256 )
524
524
with open ('/tmp/new_cm.py' , 'w' ) as f :
525
- array_list = np .array_repr (rgb , max_line_width = 78 )
526
- array_list = array_list .replace ('array(' , '' )[:- 1 ]
525
+ array_list = np .array2string (rgb , max_line_width = 78 ,
526
+ prefix = 'cm_data = ' ,
527
+ separator = ',' )
527
528
528
529
xp , yp = self .cmap_model .bezier_model .get_control_points ()
529
530
0 commit comments