python 散点图 置信区间_python matplotlib – 等高线图 – 置信区间

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 15:46   167   0

您可以指定绘制轮廓的z值列表.因此,您所要做的就是为您的发行版收集正确的z值.以下是远离峰值的“1,2和3西格玛”的示例:

码:

import numpy as np

import matplotlib.cm as cm

import matplotlib.mlab as mlab

import matplotlib.pyplot as plt

#Set up the 2D Gaussian:

delta = 0.025

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

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

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

sigma = 1.0

Z = mlab.bivariate_normal(X, Y, sigma, sigma, 0.0, 0.0)

#Get Z values for contours 1, 2, and 3 sigma away from peak:

z1 = mlab.bivariate_normal(0, 1 * sigma, sigma, sigma, 0.0, 0.0)

z2 = mlab.bivariate_normal(0, 2 * sigma, sigma, sigma, 0.0, 0.0)

z3 = mlab.bivariate_normal(0, 3 * sigma, sigma, sigma, 0.0, 0.0)

plt.figure()

#plot Gaussian:

im = plt.imshow(Z, interpolation='bilinear', origin='lower',

extent=(-50,50,-50,50),cmap=cm.gray)

#Plot contours at whatever z values we want:

CS = plt.contour(Z, [z1, z2, z3], origin='lower', extent=(-50,50,-50,50),colors='red')

plt.savefig('fig.png')

plt.show()

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP