Commit d5f599cb authored by Zhang, Chen's avatar Zhang, Chen
Browse files

add customized colormap to Mantidqt

parent 53f50166
0 172 252
0 172 252
0 168 252
0 164 252
0 160 252
0 156 252
0 152 252
0 152 252
0 148 252
0 144 252
0 140 252
0 136 252
0 132 252
0 132 252
0 128 252
0 124 252
0 120 252
0 116 252
0 112 252
0 112 252
0 108 252
0 104 252
0 100 252
0 96 252
0 92 252
0 92 252
0 88 252
0 84 252
0 80 252
0 76 252
0 72 252
0 68 252
0 64 252
0 60 252
0 56 252
0 52 252
0 48 252
0 44 252
0 40 252
0 36 252
0 32 252
0 28 252
0 24 252
0 20 252
0 16 252
0 12 252
0 8 252
0 4 252
0 4 252
4 4 248
4 4 248
8 4 244
8 8 240
12 8 240
12 8 236
16 8 232
16 12 232
20 12 228
20 12 224
24 12 224
24 16 220
28 16 216
28 16 216
32 16 212
32 20 212
36 20 208
36 20 204
40 20 204
40 24 200
44 24 196
44 24 196
48 24 192
48 24 188
52 28 188
52 28 184
56 28 180
56 28 180
60 32 176
60 32 172
64 32 172
64 32 168
68 36 168
68 36 164
72 36 160
72 36 160
76 40 156
76 40 152
80 40 152
80 40 148
84 44 144
84 44 144
88 44 140
88 44 136
92 48 136
92 48 132
96 48 128
100 48 128
100 48 124
104 52 124
104 52 120
108 52 116
108 52 116
112 56 112
112 56 108
116 56 108
116 56 104
120 60 100
120 60 100
124 60 96
124 60 92
128 64 92
128 64 88
132 64 88
132 64 84
136 68 80
136 68 80
140 68 76
140 68 72
144 72 72
144 72 68
148 72 64
148 72 64
152 72 60
152 76 56
156 76 56
156 76 52
160 76 48
160 80 48
164 80 44
164 80 44
168 80 40
168 84 36
172 84 36
172 84 32
176 84 28
176 88 28
180 88 24
180 88 20
184 88 20
184 92 16
188 92 12
188 92 12
192 92 8
196 96 4
196 96 4
196 100 4
196 100 4
196 104 4
200 108 4
200 108 4
200 112 4
200 112 4
200 116 4
204 120 4
204 120 4
204 124 4
204 124 4
208 128 4
208 132 4
208 132 4
208 136 4
208 136 4
212 140 4
212 144 4
212 144 4
212 148 4
216 152 4
216 152 4
216 156 4
216 156 4
216 160 4
220 164 4
220 164 4
220 168 4
220 168 4
224 172 4
224 176 4
224 176 4
224 180 4
224 180 4
228 184 4
228 188 4
228 188 4
228 192 4
228 192 4
232 196 4
232 200 4
232 200 4
232 204 4
236 208 4
236 208 4
236 212 4
236 212 4
236 216 4
240 220 4
240 220 4
240 224 4
240 224 4
244 228 4
244 232 4
244 232 4
244 236 4
244 236 4
248 240 4
248 244 4
248 244 4
248 248 4
252 252 0
252 252 104
252 252 104
252 252 108
252 252 112
252 252 116
252 252 120
252 252 120
252 252 124
252 252 128
252 252 132
252 252 136
252 252 136
252 252 140
252 252 144
252 252 148
252 252 152
252 252 152
252 252 156
252 252 160
252 252 164
252 252 168
252 252 168
252 252 172
252 252 176
252 252 180
252 252 184
252 252 184
252 252 188
252 252 192
252 252 196
252 252 200
252 252 200
252 252 204
252 252 208
252 252 212
252 252 216
252 252 216
252 252 220
252 252 224
252 252 228
252 252 232
252 252 232
252 252 236
252 252 240
252 252 244
252 252 248
252 252 252
......@@ -8,13 +8,14 @@
#
#
import sys
import glob
import os
from mantid.kernel import ConfigService
from mantid.plots.utility import mpl_version_info, get_current_cmap
from mantidqt.MPLwidgets import FigureCanvas
from matplotlib.colorbar import Colorbar
from matplotlib.figure import Figure
from matplotlib.colors import Normalize, SymLogNorm, PowerNorm, LogNorm
from matplotlib.colors import ListedColormap, Normalize, SymLogNorm, PowerNorm, LogNorm
from matplotlib import cm
import numpy as np
from qtpy.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLineEdit, QComboBox, QCheckBox, QLabel
......@@ -25,14 +26,31 @@ NORM_OPTS = ["Linear", "Log", "SymmetricLog10", "Power"]
MIN_LOG_VALUE = 1e-4
def register_customized_colormaps():
"""register customized colormaps to matplotlib runtime"""
print("register new map")
cmap_path = os.path.dirname(os.path.realpath(__file__))
cmap_files = glob.glob(os.path.join(cmap_path, "*.map"))
for cmap_file in cmap_files:
cmap_name = os.path.basename(cmap_file).split(".")[0]
with open(cmap_file, "r") as f:
cmap_data = np.array([list(map(float, line.split())) for line in f.readlines()])/255.0
#
cmap = ListedColormap(cmap_data, name=cmap_name)
cm.register_cmap(name=cmap_name, cmap=cmap)
class ColorbarWidget(QWidget):
colorbarChanged = Signal() # The parent should simply redraw their canvas
scaleNormChanged = Signal()
# register additional color maps from file
register_customized_colormaps()
# create the list
cmap_list = sorted([cmap for cmap in cm.cmap_d.keys() if not cmap.endswith('_r')])
def __init__(self, parent=None, default_norm_scale=None):
"""
:param default_scale: None uses linear, else either a string or tuple(string, other arguuments), e.g. tuple('Power', exponent)
:param default_scale: None uses linear, else either a string or tuple(string, other arguments), e.g. tuple('Power', exponent)
"""
super(ColorbarWidget, self).__init__(parent)
......
......@@ -13,5 +13,8 @@ setup(
install_requires=['mantid'],
version=os.environ['MANTID_VERSION_STR'],
packages=find_packages(exclude=['*.test']),
package_data={'': ['*.ui']},
package_data={
'': ['*.ui'],
'widgets': ['*.map'],
},
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment