python colormap_Python colors.LinearSegmentedColormap方法代码示例

本文整理汇总了Python中matplotlib.colors.LinearSegmentedColormap方法的典型用法代码示例。如果您正苦于以下问题:Python colors.LinearSegmentedColormap方法的具体用法?Python colors.LinearSegmentedColormap怎么用?Python colors.LinearSegmentedColormap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块matplotlib.colors的用法示例。

在下文中一共展示了colors.LinearSegmentedColormap方法的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: cmap_discretize

​点赞 6

# 需要导入模块: from matplotlib import colors [as 别名]

# 或者: from matplotlib.colors import LinearSegmentedColormap [as 别名]

def cmap_discretize(N, cmap):

"""Return a discrete colormap from the continuous colormap cmap.

Arguments:

cmap: colormap instance, eg. cm.jet.

N: number of colors.

Example:

x = resize(arange(100), (5,100))

djet = cmap_discretize(cm.jet, 5)

imshow(x, cmap=djet)

"""

if type(cmap) == str:

cmap = _plt.get_cmap(cmap)

colors_i = _np.concatenate((_np.linspace(0, 1., N), (0.,0.,0.,0.)))

colors_rgba = cmap(colors_i)

indices = _np.linspace(0, 1., N+1)

cdict = {}

for ki,key in enumerate(('red','green','blue')):

cdict[key] = [ (indices[i], colors_rgba[i-1,ki], colors_rgba[i,ki])

for i in range(N+1) ]

# Return colormap object.

return _mcolors.LinearSegmentedColormap(cmap.name + "_%d"%N, cdict, 1024)

开发者ID:LSDtopotools,项目名称:LSDMappingTools,代码行数:26,

示例2: plot_dist_f

​点赞 6

# 需要导入模块: from matplotlib import colors [as 别名]

# 或者: from matplotlib.colors import LinearSegmentedColormap [as 别名]

def plot_dist_f(v, o, prefix, suffix, summariesdir):

xkeys = range(len(v.dist_f))

ykeys = list(v.dist_f[0].keys())

f_share = np.ndarray([len(ykeys), len(xkeys)])

for x in range(f_share.shape[1]):

for y in range(f_share.shape[0]):

f_share[y, x] = v.dist_f[xkeys[x]][ykeys[y]]

ccmap = mplcolors.LinearSegmentedColormap('by_cmap', cdict2)

fig, ax = plt.subplots(dpi=300)

pcm = ax.imshow(f_share, origin='lower',

extent=[v.time[0], v.time[-1], ykeys[0], ykeys[-1]],

aspect='auto',

cmap=ccmap)

clb = fig.colorbar(pcm, ax=ax)

clb.set_label('share of given share of M13 wt fitness', y=0.5)

plt.title('Development of fitness distribution')

plt.ylabel('Fitness relative to wt M13 fitness')

plt.xlabel('Time [min]')

plt.savefig(os.path.join(summariesdir, "{}fitness_distribution_{}.png".format(prefix, suffix)))

plt.close()

开发者ID:igemsoftware2017,项目名称:AiGEM_TeamHeidelberg2017,代码行数:27,

示例3: createColormap

​点赞 6

# 需要导入模块: from matplotlib import colors [as 别名]

# 或者: from matplotlib.colors import LinearSegmentedColormap [as 别名]

def createColormap(color, min_factor=1.0, max_factor=0.95):

"""

Creates colormap with range 0-1 from white to arbitrary color.

Args:

color: Matplotlib-readable color representation. Examples: 'g', '#00FFFF', '0.5', [0.1, 0.5, 0.9]

min_factor(float): Float in the range 0-1, specifying the gray-scale color of the minimal plot value.

max_factor(float): Float in the range 0-1, multiplication factor of 'color' argument for maximal plot value.

Returns:

Colormap object to be used by matplotlib-functions

"""

rgb = colors.colorConverter.to_rgb(color)

cdict = {'red': [(0.0, min_factor, min_factor),

(1.0, max_factor*rgb[0], max_factor*rgb[0])],

'green': [(0.0, min_factor, min_factor),

(1.0, max_factor*rgb[1], max_factor*rgb[1])],

'blue': [(0.0, min_factor, min_factor),

(1.0, max_factor*rgb[2], max_factor*rgb[2])]}

return colors.LinearSegmentedColormap('custom', cdict)

开发者ID:christophmark,项目名称:bayesloop,代码行数:25,

示例4: gpf

​点赞 6

# 需要导入模块: from matplotlib import colors [as 别名]

# 或者: from matplotlib.colors import LinearSegmentedColormap [as 别名]

def gpf(self):

cmap = {"red": [], "green": [], "blue": []}

with open(self.filepath, "r") as f:

lastred = (0.0, 0.0, 0.0)

lastgreen = lastred

lastblue = lastred

line = f.readl

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值