diff --git a/examples/scripts/plot_phase_tensor_section.py b/examples/scripts/plot_phase_tensor_section.py index 162dc8dfc..ebbd69259 100644 --- a/examples/scripts/plot_phase_tensor_section.py +++ b/examples/scripts/plot_phase_tensor_section.py @@ -12,7 +12,7 @@ import os # path to edis -edi_path = r'C:\mtpywin\mtpy\examples\data\edi_files_2' +edi_path = r'c:\Users\jpeacock\Documents\GitHub\mtpy\examples\data\edi_files_2' # save path savepath = r'C:\tmp' @@ -28,8 +28,8 @@ plot_tipper = 'yri', # plot tipper ('y') + 'ri' means real+imag font_size=5, lw=0.5, - ellipse_dict = {'ellipse_colorby':'skew',# option to colour by phimin, phimax, skew, skew_seg - 'ellipse_range':[-12,12]} # set color limits - default 0,90 for phimin or max, + ellipse_dict = {'ellipse_colorby':'skew_seg',# option to colour by phimin, phimax, skew, skew_seg + 'ellipse_range':[-6, 6, 3]} # set color limits - default 0,90 for phimin or max, # [-12,12] for skew. If plotting skew_seg need to provide # 3 numbers, the 3rd indicates interval, e.g. [-12,12,3] ) diff --git a/mtpy/imaging/mtcolors.py b/mtpy/imaging/mtcolors.py index 9e262ac78..85d2aeffd 100644 --- a/mtpy/imaging/mtcolors.py +++ b/mtpy/imaging/mtcolors.py @@ -503,6 +503,7 @@ def get_plot_color(colorx, comp, cmap, ckmin=None, ckmax=None, bounds=None): return cmapdict[cmap](norm(colorx)) else: return cm.get_cmap(cmap)(norm(colorx)) + elif comp == 'skew_seg' or comp == 'normalized_skew_seg': if bounds is None: raise IOError('Need to input bounds for segmented colormap') @@ -523,8 +524,18 @@ def get_plot_color(colorx, comp, cmap, ckmin=None, ckmax=None, bounds=None): cvar = 1.0 return get_color(cvar, cmap) ''' - norm = colors.Normalize(bounds[0], bounds[-1]) + step = abs(bounds[1] - bounds[0]) + ### need to get the color into a bin so as to not smear the colors. + + if colorx > max(bounds): + colorx = max(bounds) + elif colorx < min(bounds): + colorx = min(bounds) + elif abs(colorx) <= step: + colorx = 0 + else: + colorx = int(step * round(float(colorx - np.sign(colorx) * (abs(colorx) % step))/ step)) if (cmap in list(cmapdict.keys())): return cmapdict[cmap](norm(colorx))