本文整理汇总了Python中matplotlib.cbook.boxplot_stats方法的典型用法代码示例。如果您正苦于以下问题:Python cbook.boxplot_stats方法的具体用法?Python cbook.boxplot_stats怎么用?Python cbook.boxplot_stats使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.cbook
的用法示例。
在下文中一共展示了cbook.boxplot_stats方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_results_bootstrapped
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import boxplot_stats [as 别名]
def test_results_bootstrapped(self):
results = cbook.boxplot_stats(self.data, bootstrap=10000)
res = results[0]
for key in list(self.known_bootstrapped_ci.keys()):
assert_approx_equal(
res[key],
self.known_bootstrapped_ci[key]
)
示例2: test_results_whiskers_float
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import boxplot_stats [as 别名]
def test_results_whiskers_float(self):
results = cbook.boxplot_stats(self.data, whis=3)
res = results[0]
for key in list(self.known_whis3_res.keys()):
if key != 'fliers':
assert_statement = assert_approx_equal
else:
assert_statement = assert_array_almost_equal
assert_statement(
res[key],
self.known_whis3_res[key]
)
示例3: test_results_whiskers_range
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import boxplot_stats [as 别名]
def test_results_whiskers_range(self):
results = cbook.boxplot_stats(self.data, whis='range')
res = results[0]
for key in list(self.known_res_range.keys()):
if key != 'fliers':
assert_statement = assert_approx_equal
else:
assert_statement = assert_array_almost_equal
assert_statement(
res[key],
self.known_res_range[key]
)
示例4: test_results_whiskers_percentiles
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import boxplot_stats [as 别名]
def test_results_whiskers_percentiles(self):
results = cbook.boxplot_stats(self.data, whis=[5, 95])
res = results[0]
for key in list(self.known_res_percentiles.keys()):
if key != 'fliers':
assert_statement = assert_approx_equal
else:
assert_statement = assert_array_almost_equal
assert_statement(
res[key],
self.known_res_percentiles[key]
)
示例5: test_label_error
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import boxplot_stats [as 别名]
def test_label_error(self):
labels = [1, 2]
results = cbook.boxplot_stats(self.data, labels=labels)
示例6: test_bad_dims
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import boxplot_stats [as 别名]
def test_bad_dims(self):
data = np.random.normal(size=(34, 34, 34))
results = cbook.boxplot_stats(data)
示例7: test_results_bootstrapped
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import boxplot_stats [as 别名]
def test_results_bootstrapped(self):
results = cbook.boxplot_stats(self.data, bootstrap=10000)
res = results[0]
for key, value in self.known_bootstrapped_ci.items():
assert_approx_equal(res[key], value)
示例8: test_results_whiskers_float
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import boxplot_stats [as 别名]
def test_results_whiskers_float(self):
results = cbook.boxplot_stats(self.data, whis=3)
res = results[0]
for key, value in self.known_whis3_res.items():
assert_array_almost_equal(res[key], value)
示例9: test_results_whiskers_range
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import boxplot_stats [as 别名]
def test_results_whiskers_range(self):
results = cbook.boxplot_stats(self.data, whis='range')
res = results[0]
for key, value in self.known_res_range.items():
assert_array_almost_equal(res[key], value)
示例10: test_results_whiskers_percentiles
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import boxplot_stats [as 别名]
def test_results_whiskers_percentiles(self):
results = cbook.boxplot_stats(self.data, whis=[5, 95])
res = results[0]
for key, value in self.known_res_percentiles.items():
assert_array_almost_equal(res[key], value)
示例11: test_label_error
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import boxplot_stats [as 别名]
def test_label_error(self):
labels = [1, 2]
with pytest.raises(ValueError):
results = cbook.boxplot_stats(self.data, labels=labels)
示例12: test_bad_dims
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import boxplot_stats [as 别名]
def test_bad_dims(self):
data = np.random.normal(size=(34, 34, 34))
with pytest.raises(ValueError):
results = cbook.boxplot_stats(data)
示例13: test_boxplot_stats_autorange_false
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import boxplot_stats [as 别名]
def test_boxplot_stats_autorange_false(self):
x = np.zeros(shape=140)
x = np.hstack([-25, x, 25])
bstats_false = cbook.boxplot_stats(x, autorange=False)
bstats_true = cbook.boxplot_stats(x, autorange=True)
assert bstats_false[0]['whislo'] == 0
assert bstats_false[0]['whishi'] == 0
assert_array_almost_equal(bstats_false[0]['fliers'], [-25, 25])
assert bstats_true[0]['whislo'] == -25
assert bstats_true[0]['whishi'] == 25
assert_array_almost_equal(bstats_true[0]['fliers'], [])
示例14: compute_group
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import boxplot_stats [as 别名]
def compute_group(cls, data, scales, **params):
labels = ['x', 'y']
X = np.array(data[labels])
res = boxplot_stats(X, whis=params['coef'], labels=labels)[1]
try:
n = data['weight'].sum()
except KeyError:
n = len(data['y'])
if len(np.unique(data['x'])) > 1:
width = np.ptp(data['x']) * 0.9
else:
width = params['width']
if pdtypes.is_categorical(data['x']):
x = data['x'].iloc[0]
else:
x = np.mean([data['x'].min(), data['x'].max()])
d = {'ymin': res['whislo'],
'lower': res['q1'],
'middle': [res['med']],
'upper': res['q3'],
'ymax': res['whishi'],
'outliers': [res['fliers']],
'notchupper': res['med']+1.58*res['iqr']/np.sqrt(n),
'notchlower': res['med']-1.58*res['iqr']/np.sqrt(n),
'x': x,
'width': width,
'relvarwidth': np.sqrt(n)}
return pd.DataFrame(d)
示例15: setup
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import boxplot_stats [as 别名]
def setup(self):
np.random.seed(937)
self.nrows = 37
self.ncols = 4
self.data = np.random.lognormal(size=(self.nrows, self.ncols),
mean=1.5, sigma=1.75)
self.known_keys = sorted([
'mean', 'med', 'q1', 'q3', 'iqr',
'cilo', 'cihi', 'whislo', 'whishi',
'fliers', 'label'
])
self.std_results = cbook.boxplot_stats(self.data)
self.known_nonbootstrapped_res = {
'cihi': 6.8161283264444847,
'cilo': -0.1489815330368689,
'iqr': 13.492709959447094,
'mean': 13.00447442387868,
'med': 3.3335733967038079,
'fliers': np.array([
92.55467075, 87.03819018, 42.23204914, 39.29390996
]),
'q1': 1.3597529879465153,
'q3': 14.85246294739361,
'whishi': 27.899688243699629,
'whislo': 0.042143774965502923
}
self.known_bootstrapped_ci = {
'cihi': 8.939577523357828,
'cilo': 1.8692703958676578,
}
self.known_whis3_res = {
'whishi': 42.232049135969874,
'whislo': 0.042143774965502923,
'fliers': np.array([92.55467075, 87.03819018]),
}
self.known_res_percentiles = {
'whislo': 0.1933685896907924,
'whishi': 42.232049135969874
}
self.known_res_range = {
'whislo': 0.042143774965502923,
'whishi': 92.554670752188699
}