本文整理汇总了Python中matplotlib.colors.Normalize.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Normalize.__init__方法的具体用法?Python Normalize.__init__怎么用?Python Normalize.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.colors.Normalize
的用法示例。
在下文中一共展示了Normalize.__init__方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import __init__ [as 别名]
def __init__(self):
Normalize.__init__(self)
self.stretch = "linear"
self.bias = 0.5
self.contrast = 0.5
self.clip_lo = 5.0
self.clip_hi = 95.0
示例2: __init__
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import __init__ [as 别名]
def __init__(self, stretch='linear', exponent=5, vmid=None, vmin=None,
vmax=None, clip=False):
'''
Initalize an APLpyNormalize instance.
Optional Keyword Arguments:
*vmin*: [ None | float ]
Minimum pixel value to use for the scaling.
*vmax*: [ None | float ]
Maximum pixel value to use for the scaling.
*stretch*: [ 'linear' | 'log' | 'sqrt' | 'arcsinh' | 'power' ]
The stretch function to use (default is 'linear').
*vmid*: [ None | float ]
Mid-pixel value used for the log and arcsinh stretches. If
set to None, a default value is picked.
*exponent*: [ float ]
if self.stretch is set to 'power', this is the exponent to use.
*clip*: [ True | False ]
If clip is True and the given value falls outside the range,
the returned value will be 0 or 1, whichever is closer.
'''
if vmax < vmin:
raise Exception("vmax should be larger than vmin")
# Call original initalization routine
Normalize.__init__(self, vmin=vmin, vmax=vmax, clip=clip)
# Save parameters
self.stretch = stretch
self.exponent = exponent
if stretch == 'power' and np.equal(self.exponent, None):
raise Exception("For stretch=='power', an exponent should be specified")
if np.equal(vmid, None):
if stretch == 'log':
if vmin > 0:
self.midpoint = vmax / vmin
else:
raise Exception("When using a log stretch, if vmin < 0, then vmid has to be specified")
elif stretch == 'arcsinh':
self.midpoint = -1./30.
else:
self.midpoint = None
else:
if stretch == 'log':
if vmin < vmid:
raise Exception("When using a log stretch, vmin should be larger than vmid")
self.midpoint = (vmax - vmid) / (vmin - vmid)
elif stretch == 'arcsinh':
self.midpoint = (vmid - vmin) / (vmax - vmin)
else:
self.midpoint = None
示例3: __init__
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import __init__ [as 别名]
def __init__(self, vmin=None, vmax=None, midpoint=0, clip=False):
"""
Copied from SO answer: http://stackoverflow.com/questions/20144529/shifted-colorbar-matplotlib
:param vmin:
:param vmax:
:param midpoint:
:param clip:
"""
self.midpoint = midpoint
Normalize.__init__(self, vmin, vmax, clip)
示例4: __init__
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import __init__ [as 别名]
def __init__(self, vmin=None, vmax=None, midpoint=None,
clip=False, nlevs=9):
""".. warning::
MidpointNormalize is deprecated and will be removed in
future versions. Please use
:class:`timutils.get_discrete_midpt_cmap_norm` instead
returns a colormap and a matplotlib.colors.Normalize
instance that implement a *continuous* colormap with an
arbitrary midpoint.
ARGS:
vmin (real): the minimum value in the colormap
vmax (real): the maximum value in the colormap
midpoint (real): the midpoint to center on
clip (boolean):
nlevs (integer): number of levels to divide the colormap
into. Not currently functional.
EXAMPLE:
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> from timutils.midpt_norm import MidpointNormalize
>>> plt.close('all')
>>> data = np.random.randint(-120, 20, [124, 124])
>>> fix, ax = plt.subplots(1, 2)
>>> mycmap = plt.get_cmap('Blues')
>>> mynorm = MidpointNormalize(vmin=-120, vmax=20, midpoint=0.0)
>>> cm = ax[0].pcolormesh(data, norm=mynorm, cmap=mycmap)
>>> plt.colorbar(cm, cax=ax[1], norm=mynorm, cmap=mycmap)
>>> plt.show()
adapted by Timothy W. Hilton from `code posted by Joe Kington
<http://stackoverflow.com/questions/20144529/shifted-colorbar-matplotlib>`_
accessed 19 January 2015
"""
warnings.warn(('MidpointNormalize is (1) deprecated and (2)'
'buggy and will be' 'removed in future versions. '
'Please use get_discrete_midpt_cmap_norm instead'))
self.midpoint = midpoint
self.nlevs = nlevs
Normalize.__init__(self, vmin, vmax, clip)
示例5: __init__
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import __init__ [as 别名]
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):
self.midpoint = midpoint
Normalize.__init__(self, vmin, vmax, clip)
示例6: __init__
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import __init__ [as 别名]
def __init__(self,linthresh,vmin=None,vmax=None,clip=False):
Normalize.__init__(self,vmin,vmax,clip)
self.linthresh=linthresh
self.vmin, self.vmax = vmin, vmax
示例7: __init__
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import __init__ [as 别名]
def __init__(self, vmin=None, vmax=None, vanchor=None,
clip=False, canchor=0.5):
self.vanchor = vanchor
self.canchor = canchor
Normalize.__init__(self, vmin, vmax, clip)
示例8: __init__
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import __init__ [as 别名]
def __init__(self,vmin=None,vmax=None,clip=False):
Normalize.__init__(self,vmin,vmax,clip)
示例9: __init__
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import __init__ [as 别名]
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):
"""
Requires a midpoint value
"""
self.midpoint = midpoint
Normalize.__init__(self, vmin, vmax, clip)
示例10: __init__
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import __init__ [as 别名]
def __init__(self, vmin=None, vmax=None, clip=False, vin=None, cin=0.01):
self.vin = vin
self.cin = cin
Normalize.__init__(self, vmin, vmax, clip)
示例11: __init__
# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import __init__ [as 别名]
def __init__(self, epoch0, epoch1):
Normalize.__init__(self, self.mktime(epoch0), self.mktime(epoch1))