本文整理汇总了Python中reprep.Report.plot方法的典型用法代码示例。如果您正苦于以下问题:Python Report.plot方法的具体用法?Python Report.plot怎么用?Python Report.plot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reprep.Report
的用法示例。
在下文中一共展示了Report.plot方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_ex16c_r
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import plot [as 别名]
def check_ex16c_r(dp):
# from mocdp.dp.dp_loop import SimpleLoop
# funsp = dp.get_fun_space()
# assert isinstance(dp, SimpleLoop)
# Payload2ET
dp1 = dp.dp1.dp1
payload1 = 10.0
payload2 = 12.0
# bot = dp1.get._fun_space().get_bottom()
res1 = dp1.solve(payload1)
res2 = dp1.solve(payload2)
r = Report()
caption = 'Two curves for each payload'
with r.plot('p1', caption=caption) as pylab:
plot_upset_minima(pylab, res1)
plot_upset_minima(pylab, res2)
axis = pylab.axis()
plot_upset_R2(pylab, res1, axis, color_shadow=[0.5, 0.5, 0.5])
plot_upset_R2(pylab, res2, axis, color_shadow=[0.7, 0.7, 0.6])
pylab.xlabel('time')
pylab.ylabel('energy')
import numpy as np
payloads = np.linspace(0, 100, 100)
payloads_ = []
payload2payload = dp.dp1
for p in payloads:
res = payload2payload.solve(p)
assert len(res.minimals) == 1
pp = list(res.minimals)[0]
payloads_.append(pp)
with r.plot('p2') as pylab:
pylab.plot(payloads, payloads, 'k--')
pylab.plot(payloads, payloads_, 'r.')
pylab.xlabel('payload (g)')
pylab.ylabel('payload (g)')
pylab.xlim(0, max(payloads))
# pylab.ylim(0, max(payloads))
return r
示例2: plot
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import plot [as 别名]
def plot(self, name, **args):
name = normalize(name)
r = Report()
a = r.plot('plot', mime=MIME_PNG, **args)
# XXX: better way?
yield a.__enter__()
a.__exit__(None, None, None)
data_node = r.children[0]
rgb = data_node.get_rgb()
self.bitmap(name, rgb)
示例3: main
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import plot [as 别名]
def main():
np.seterr(all='warn')
n = 100
z = np.linspace(-1, 1, n)
z_order = np.array(range(n))
alpha = 0.1
base = 0.3
noise_eff = 0.05
noise_est = noise_eff
f_L = lambda z: np.exp(-np.abs(+1 - np.maximum(z, 0)) / alpha) + base
f_R = lambda z: np.exp(-np.abs(-1 - np.minimum(z, 0)) / alpha) + base
rate_L0 = f_L(z)
rate_R0 = f_R(z)
simulate_L = lambda: f_L(z) + np.random.uniform(-1, 1, n) * noise_eff
simulate_R = lambda: f_R(z) + np.random.uniform(-1, 1, n) * noise_eff
rate_L = simulate_L()
rate_R = simulate_R()
T = 100
ord1 = np.zeros((n, T))
for k in range(T):
ord1[:, k] = scale_score(simulate_L())
order_L_sim = np.ndarray(n, fit_dtype)
for i in range(n):
order_L_sim[i]['mean'] = np.mean(ord1[i, :])
l, u = np.percentile(ord1[i, :], [5, 95])
order_L_sim[i]['upper'] = u
order_L_sim[i]['lower'] = l
rate_L_est = np.ndarray(n, fit_dtype)
rate_L_est['upper'] = rate_L + noise_est
rate_L_est['lower'] = rate_L - noise_est
rate_R_est = np.ndarray(n, fit_dtype)
rate_R_est['upper'] = rate_R + noise_est
rate_R_est['lower'] = rate_R - noise_est
# estimate according to naive procedure
z_naive = estimate_stimulus_naive(rate_L, rate_R)
res = estimate_stimulus(rate_L_est, rate_R_est)
L_order = res.L_order
R_order = res.R_order
scale_rate = max(rate_L.max(), rate_R.max()) * 1.2
cL = 'r'
cR = 'b'
r = Report()
f = r.figure(cols=3)
with r.plot('noiseless') as pylab:
pylab.plot(z, rate_L0, '%s-' % cL)
pylab.plot(z, rate_R0, '%s-' % cR)
pylab.axis((-1, 1, 0.0, scale_rate))
r.last().add_to(f, caption='noiseless rates')
with r.plot('observed_rates') as pylab:
pylab.plot(z, rate_R0, '%s-' % cR)
pylab.plot(z, rate_L0, '%s-' % cL)
plot_rate_bars(pylab, z, rate_L_est, '%s' % cL)
plot_rate_bars(pylab, z, rate_R_est, '%s' % cR)
pylab.axis((-1, 1, 0.0, scale_rate))
r.last().add_to(f, caption='true_rates')
with r.plot('M') as pylab:
pylab.plot(z, rate_L0, '%s-' % cL)
pylab.plot(z, rate_R0, '%s-' % cR)
pylab.axis((-1, 1, 0.0, scale_rate))
with r.plot('z_naive') as pylab:
pylab.plot(z_naive, rate_L, '%s.' % cL)
pylab.plot(z_naive, rate_R, '%s.' % cR)
pylab.axis((-1, 1, 0.0, scale_rate))
r.last().add_to(f, caption='Stimulus estimated in naive way.')
with r.plot('simulated_order_stats') as pylab:
pylab.plot([0, 0], [n, n], 'k-')
pylab.plot([0, n], [n, 0], 'k-')
pylab.plot(z_order, order_L_sim['mean'], '%s.' % cL)
plot_rate_bars(pylab, z_order, order_L_sim, '%s' % cL)
pylab.axis((0, n, -n / 10, n * 1.1))
pylab.axis('equal')
r.last().add_to(f, caption='Orders as found by simulation')
with r.plot('estimated_order') as pylab:
pylab.plot(z, L_order['mean'], '%s.' % cL)
pylab.plot(z, R_order['mean'], '%s.' % cR)
pylab.axis((-1, 1, -n / 2, n * 3 / 2))
r.last().add_to(f, caption='estimated_order')
with r.plot('estimated_order_order') as pylab:
#.........这里部分代码省略.........
示例4: report
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import plot [as 别名]
def report(res):
r = Report()
dataL = res['dataL']
dataU = res['dataU']
what_to_plot_res = dict(total_cost="USD", total_mass='kg')
what_to_plot_fun = dict(endurance="hour", extra_payload="g")
queries = dataL['queries']
endurance = [q['endurance'] for q in queries]
def get_value(data, field):
for res in data['results']:
a = to_numpy_array({field: 'kg'}, res)
if len(a):
a = min(a[field])
else:
a = None
yield a
from matplotlib import pylab
ieee_fonts_zoom3(pylab)
markers = dict(markeredgecolor='none', markerfacecolor='black', markersize=6,
marker='o')
LOWER2 = dict(color='orange', linewidth=4, linestyle='-', clip_on=False)
UPPER2 = dict(color='purple', linewidth=4, linestyle='-', clip_on=False)
LOWER2.update(markers)
UPPER2.update(markers)
color_resources = '#700000'
color_functions = '#007000'
fig = dict(figsize=(4.5, 4))
with r.plot('total_mass', **fig) as pylab:
ieee_spines_zoom3(pylab)
total_massL = np.array(list(get_value(dataL, 'total_mass')))
total_massU = np.array(list(get_value(dataU, 'total_mass')))
print endurance
print total_massL, total_massU
pylab.plot(endurance, total_massL, **LOWER2)
pylab.plot(endurance, total_massU, **UPPER2)
set_axis_colors(pylab, color_functions, color_resources)
pylab.xlabel('endurance [hours]')
pylab.ylabel('total_mass [kg]')
return r
print('Plotting lower')
with r.subsection('lower') as rL:
plot_all_directions(rL,
queries=dataL['queries'],
results=dataL['results'],
what_to_plot_res=what_to_plot_res,
what_to_plot_fun=what_to_plot_fun)
print('Plotting upper')
with r.subsection('upper') as rU:
plot_all_directions(rU,
queries=dataU['queries'],
results=dataU['results'],
what_to_plot_res=what_to_plot_res,
what_to_plot_fun=what_to_plot_fun)
return r