Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:MTgeophysics/mtpy into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
zhang01GA committed May 2, 2019
2 parents 8debc3b + e00483a commit b9dd5ee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 3 additions & 3 deletions examples/scripts/plot_phase_tensor_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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]
)
Expand Down
13 changes: 12 additions & 1 deletion mtpy/imaging/mtcolors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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))
Expand Down

0 comments on commit b9dd5ee

Please sign in to comment.