python label函数_Python pyplot.clabel方法代码示例

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

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

示例1: visualizeFit

​点赞 6

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

# 或者: from matplotlib.pyplot import clabel [as 别名]

def visualizeFit(X,mu,sigma2):

x = np.arange(0, 36, 0.5) # 0-36,步长0.5

y = np.arange(0, 36, 0.5)

X1,X2 = np.meshgrid(x,y) # 要画等高线,所以meshgird

Z = multivariateGaussian(np.hstack((X1.reshape(-1,1),X2.reshape(-1,1))), mu, sigma2) # 计算对应的高斯分布函数

Z = Z.reshape(X1.shape) # 调整形状

plt.plot(X[:,0],X[:,1],'bx')

if np.sum(np.isinf(Z).astype(float)) == 0: # 如果计算的为无穷,就不用画了

#plt.contourf(X1,X2,Z,10.**np.arange(-20, 0, 3),linewidth=.5)

CS = plt.contour(X1,X2,Z,10.**np.arange(-20, 0, 3),color='black',linewidth=.5) # 画等高线,Z的值在10.**np.arange(-20, 0, 3)

#plt.clabel(CS)

plt.show()

# 选择最优的epsilon,即:使F1Score最大

开发者ID:lawlite19,项目名称:MachineLearning_Python,代码行数:18,

示例2: test_collection

​点赞 6

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

# 或者: from matplotlib.pyplot import clabel [as 别名]

def test_collection():

x, y = np.meshgrid(np.linspace(0, 10, 150), np.linspace(-5, 5, 100))

data = np.sin(x) + np.cos(y)

cs = plt.contour(data)

pe = [path_effects.PathPatchEffect(edgecolor='black', facecolor='none',

linewidth=12),

path_effects.Stroke(linewidth=5)]

for collection in cs.collections:

collection.set_path_effects(pe)

for text in plt.clabel(cs, colors='white'):

text.set_path_effects([path_effects.withStroke(foreground='k',

linewidth=3)])

text.set_bbox({'boxstyle': 'sawtooth', 'facecolor': 'none',

'edgecolor': 'blue'})

开发者ID:miloharper,项目名称:neural-network-animation,代码行数:18,

示例3: test_labels

​点赞 6

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

# 或者: from matplotlib.pyplot import clabel [as 别名]

def test_labels():

# Adapted from pylab_examples example code: contour_demo.py

# see issues #2475, #2843, and #2818 for explanation

delta = 0.025

x = np.arange(-3.0, 3.0, delta)

y = np.arange(-2.0, 2.0, delta)

X, Y = np.meshgrid(x, y)

Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)

Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)

# difference of Gaussians

Z = 10.0 * (Z2 - Z1)

fig, ax = plt.subplots(1, 1)

CS = ax.contour(X, Y, Z)

disp_units = [(216, 177), (359, 290), (521, 406)]

data_units = [(-2, .5), (0, -1.5), (2.8, 1)]

CS.clabel()

for x, y in data_units:

CS.add_label_near(x, y, inline=True, transform=None)

for x, y in disp_units:

CS.add_label_near(x, y, inline=True, transform=False)

开发者ID:miloharper,项目名称:neural-network-animation,代码行数:26,

示例4: Pcolor

​点赞 6

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

# 或者: from matplotlib.pyplot import clabel [as 别名]

def Pcolor(xs, ys, zs, pcolor=True, contour=False, **options):

"""Makes a pseudocolor plot.

xs:

ys:

zs:

pcolor: boolean, whether to make a pseudocolor plot

contour: boolean, whether to make a contour plot

options: keyword args passed to plt.pcolor and/or plt.contour

"""

_Underride(options, linewidth=3, cmap=matplotlib.cm.Blues)

X, Y = np.meshgrid(xs, ys)

Z = zs

x_formatter = matplotlib.ticker.ScalarFormatter(useOffset=False)

axes = plt.gca()

axes.xaxis.set_major_formatter(x_formatter)

if pcolor:

plt.pcolormesh(X, Y, Z, **options)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值