本文整理汇总了Python中graphs.Graph.gca方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.gca方法的具体用法?Python Graph.gca怎么用?Python Graph.gca使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphs.Graph
的用法示例。
在下文中一共展示了Graph.gca方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeResults
# 需要导入模块: from graphs import Graph [as 别名]
# 或者: from graphs.Graph import gca [as 别名]
def makeResults(cls, methods, checkName="bw", saveResults=True):
"""Make result to graphics
:param methods : results to process
:param checkName: name of the current check being processed
:param saveResults : save results to json file ?"""
if saveResults:
try:
fn = cls.saveResults(methods, checkName)
info("Saved bandwidth results to file %s\n" % fn)
except Exception as e:
error("Could not save bandwidth results : %s\n" % e)
import numpy as np
from matplotlib.backends.backend_pdf import PdfPages
try:
for name, method in methods.iteritems():
info("Result of measures for method %s:" % name)
for pair in method["pairs"]:
info(pair.printAll())
info("\n")
except Exception as e:
error("Could not print results %s\n" % e)
nmethods = len(methods)
gr = 1
ncols = 3
nlines = nmethods
nbins = 15
# dict(step : dict(method, data))
# mboxes = {}
try:
fn = "checks/%s.pdf" % checkName
pdf = PdfPages(fn)
for name, method in methods.iteritems():
avgs = {}
ts = {}
adiffs = {}
rdiffs = {}
steps = {"total": None}
for target, tsteps in method["real_steps"].iteritems():
st = zip(*tsteps)
step_time = np.array((0,) + st[1])
step_values = np.array((0,) + st[0])
steps[target] = (step_time, step_values)
steps["total"] = (
(step_time, np.minimum(steps["total"][1], step_values))
if steps["total"] is not None
else (step_time, step_values)
)
for pair in method["pairs"]:
avg = map(lambda measure: measure.bw / (1000 ** 2), pair.measures)
adiff = map(lambda measure: measure.bw / (1000 ** 2) - measure.step, pair.measures)
rdiff = map(
lambda measure: abs(measure.bw / (1000.0 ** 2) - measure.step) / float(measure.step),
pair.measures,
)
t = map(lambda measure: measure.timestamp, pair.measures)
avgs[pair.getPair()] = np.array(avg)
ts[pair.getPair()] = np.array(t)
adiffs[pair.getPair()] = np.array(adiff)
rdiffs[pair.getPair()] = np.array(rdiff)
# plot the data
Graph.subplot(nlines, ncols, gr)
for pair in method["pairs"]:
Graph.scatter(
ts[pair.getPair()],
avgs[pair.getPair()],
color=Graph.getColor(pair.getPair()),
label="%s,%s" % pair.getPair(),
)
Graph.hold = True
for target, tsteps in steps.iteritems():
Graph.step(tsteps[0], tsteps[1], "r", where="post", label=target, color=Graph.getColor(target))
Graph.hold = True
Graph.decorate(
g_xlabel="Time (s)",
g_ylabel="BW estimation with %s (Mbps)" % name,
g_title="Measure for Bandwidth for tool %s" % name,
)
ax = Graph.gca()
ax.set_yscale("log")
Graph.legend(loc=2)
Graph.draw()
Graph.subplot(nlines, ncols, gr + 1)
Graph.hist(
rdiffs.values(),
nbins,
label=["%s,%s" % x for x in rdiffs.keys()],
g_xlabel="Relative error",
g_title="Relative error for tool %s" % name,
)
Graph.legend(loc=2)
# ax = Graph.gca()
# ax.set_yscale('log')
#.........这里部分代码省略.........