本文整理匯總了Python中pychron.graph.graph.Graph.set_y_limits方法的典型用法代碼示例。如果您正苦於以下問題:Python Graph.set_y_limits方法的具體用法?Python Graph.set_y_limits怎麽用?Python Graph.set_y_limits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pychron.graph.graph.Graph
的用法示例。
在下文中一共展示了Graph.set_y_limits方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _graph_factory
# 需要導入模塊: from pychron.graph.graph import Graph [as 別名]
# 或者: from pychron.graph.graph.Graph import set_y_limits [as 別名]
def _graph_factory(self, **kw):
g = Graph(
window_height=250,
window_width=300,
container_dict=dict(padding=0))
g.new_plot(
bounds=[250, 250],
resizable='',
padding=[30, 0, 0, 30])
cx = self.cx
cy = self.cy
cbx = self.xbounds
cby = self.ybounds
tr = self.target_radius
g.set_x_limits(*cbx)
g.set_y_limits(*cby)
lp, _plot = g.new_series()
t = TargetOverlay(component=lp,
cx=cx,
cy=cy,
target_radius=tr)
lp.overlays.append(t)
overlap_overlay = OverlapOverlay(component=lp,
visible=self.show_overlap)
lp.overlays.append(overlap_overlay)
self._graph_factory_hook(lp)
g.new_series(type='scatter', marker='circle')
g.new_series(type='line', color='red')
return g
示例2: _graph_factory
# 需要導入模塊: from pychron.graph.graph import Graph [as 別名]
# 或者: from pychron.graph.graph.Graph import set_y_limits [as 別名]
def _graph_factory(self, with_image=False):
g = Graph(window_height=250, window_width=300, container_dict=dict(padding=0))
g.new_plot(bounds=[250, 250], resizable="", padding=[30, 0, 0, 30])
cx = self.cx
cy = self.cy
cbx = self.xbounds
cby = self.ybounds
tr = self.target_radius
# if with_image:
# px = self.pxpermm #px is in mm
# cbx, cby = self._get_crop_bounds()
# #g.set_axis_traits(tick_label_formatter=lambda x: '{:0.2f}'.format((x - w / 2) / px))
# #g.set_axis_traits(tick_label_formatter=lambda x: '{:0.2f}'.format((x - h / 2) / px), axis='y')
#
# bx, by = g.plots[0].bounds
# g.plots[0].x_axis.mapper = LinearMapper(high_pos=bx,
# range=DataRange1D(low_setting=self.xbounds[0],
# high_setting=self.xbounds[1]))
# g.plots[0].y_axis.mapper = LinearMapper(high_pos=by,
# range=DataRange1D(low_setting=self.ybounds[0],
# high_setting=self.ybounds[1]))
# cx += self.image_width / 2
# cy += self.image_height / 2
# tr *= px
g.set_x_limits(*cbx)
g.set_y_limits(*cby)
lp, _plot = g.new_series()
t = TargetOverlay(component=lp, cx=cx, cy=cy, target_radius=tr)
lp.overlays.append(t)
overlap_overlay = OverlapOverlay(component=lp, visible=self.show_overlap)
lp.overlays.append(overlap_overlay)
g.new_series(type="scatter", marker="circle")
g.new_series(type="line", color="red")
return g
示例3: int
# 需要導入模塊: from pychron.graph.graph import Graph [as 別名]
# 或者: from pychron.graph.graph.Graph import set_y_limits [as 別名]
mswds1.append(ms1)
rratios1.append(ratios1)
if tau % 5 == 0:
g.new_series(x, ratios1, plotid=1, type='line')
i = int((tau / 5) - 1)
# g.set_series_label('p', plotid=1, series=i)
# g.set_series_label('{} (ns)'.format(tau), plotid=1, series=i)
# g.plots[1].legend.plots = dict([(k, v[0]) for k, v in g.plots[1].plots.iteritems()])
# print g.plots[1].legend.plots
g.new_series(taus, mswds1, plotid=0, type='line_scatter')
g.set_y_limits(min(mswds1) - 5, max(mswds1) + 5, plotid=0)
# fit parabola and find minimum.
coeffs1 = polyfit(taus, mswds1, 2)
# min at dy=0 (ax2+bx+c)dx=dy==2ax+b
# 2ax+b=0 , x=-b/(2a)
dt = -coeffs1[1] / (2 * coeffs1[0])
print 'dead time1= ', dt
g.set_x_title('# Airshots', plotid=1)
g.set_x_title('Dead Time (ns)', plotid=0)
g.set_y_title('40Ar/36Ar', plotid=1)
g.set_y_title('MSWD', plotid=0)
g.add_vertical_rule(dt)
示例4: max
# 需要導入模塊: from pychron.graph.graph import Graph [as 別名]
# 或者: from pychron.graph.graph.Graph import set_y_limits [as 別名]
xs, ys = poly.T
cx, cy = xs.mean(), ys.mean()
P = poly.T
xs = np.hstack((xs, xs[0]))
ys = np.hstack((ys, ys[0]))
else:
xs, ys = poly.T
xs = np.hstack((xs, xs[0]))
ys = np.hstack((ys, ys[0]))
cx, cy = xs.mean(), ys.mean()
# plot original
g.new_series(xs, ys)
g.set_x_limits(min(xs), max(xs), pad="0.1")
g.set_y_limits(min(ys), max(ys), pad="0.1")
for ps in npoints:
for i in range(0, len(ps), 2):
p1, p2 = ps[i], ps[i + 1]
g.new_series((p1[0], p2[0]), (p1[1], p2[1]), color="black")
# plot offset polygon
# poly = sort_clockwise(poly, poly)
opoly = polygon_offset(poly, -500)
if use_convex_hull:
opoly = convex_hull(opoly)
xs, ys, _ = opoly.T
xs = np.hstack((xs, xs[0]))
ys = np.hstack((ys, ys[0]))
else:
示例5: _execute_seek
# 需要導入模塊: from pychron.graph.graph import Graph [as 別名]
# 或者: from pychron.graph.graph.Graph import set_y_limits [as 別名]
def _execute_seek(self, controller, pattern):
from pychron.core.ui.gui import invoke_in_main_thread
from pychron.graph.graph import Graph
duration = pattern.duration
g = Graph()
g.edit_traits()
g.new_plot()
s, p = g.new_series()
g.new_plot()
g.new_series(type='line')
cp = CurrentPointOverlay(component=s)
s.overlays.append(cp)
w = 2
g.set_x_limits(-w, w)
g.set_y_limits(-w, w)
om = 60
g.set_x_limits(max_=om, plotid=1)
lm = self.laser_manager
sm = lm.stage_manager
st = time.time()
def update_graph(zs, zz, xx, yy):
cp.point = (xx, yy)
g.add_datum((xx, yy), plotid=0)
t = time.time() - st
g.add_datum((t, zz),
update_y_limits=True,
plotid=1)
g.add_datum((t,) * len(zs), zs,
update_y_limits=True,
plotid=1, series=1)
g.set_x_limits(max_=max(om, t + 10), plotid=1)
g.redraw()
pp = os.path.join(paths.data_dir, 'seek_pattern.txt')
with open(pp, 'w') as wfile:
cx, cy = pattern.cx, pattern.cy
wfile.write('{},{}\n'.format(cx, cy))
wfile.write('#z, x, y, n\n')
gen = pattern.point_generator()
for x, y in gen:
if not self._alive:
break
with PeriodCTX(1):
# x, y = gen.next()
# x, y = pattern.next_point
controller.linear_move(cx + x, cy + y, block=False, velocity=pattern.velocity)
mt = time.time()
zs = []
while sm.moving():
_, _, v = sm.get_brightness()
zs.append(v)
while 1:
if time.time() - mt > duration:
break
_, _, v = sm.get_brightness()
zs.append(v)
if zs:
n = len(zs)
z = sum(zs) / float(n)
self.debug('XY:({},{}) Z:{}, N:{}'.format(x, y, z, n))
pattern.set_point(z, x, y)
wfile.write('{:0.5f},{:0.3f},{:0.3f},{}\n'.format(z, x, y, n))
invoke_in_main_thread(update_graph, zs, z, x, y)
g.close_ui()
示例6: max
# 需要導入模塊: from pychron.graph.graph import Graph [as 別名]
# 或者: from pychron.graph.graph.Graph import set_y_limits [as 別名]
xs, ys = poly.T
cx, cy = xs.mean(), ys.mean()
P = poly.T
xs = np.hstack((xs, xs[0]))
ys = np.hstack((ys, ys[0]))
else:
xs, ys = poly.T
xs = np.hstack((xs, xs[0]))
ys = np.hstack((ys, ys[0]))
cx, cy = xs.mean(), ys.mean()
# plot original
g.new_series(xs, ys)
g.set_x_limits(min(xs), max(xs), pad='0.1')
g.set_y_limits(min(ys), max(ys), pad='0.1')
for ps in npoints:
for i in range(0, len(ps), 2):
p1, p2 = ps[i], ps[i + 1]
g.new_series((p1[0], p2[0]),
(p1[1], p2[1]), color='black')
# plot offset polygon
# poly = sort_clockwise(poly, poly)
opoly = polygon_offset(poly, -500)
if use_convex_hull:
opoly = convex_hull(opoly)
xs, ys, _ = opoly.T
xs = np.hstack((xs, xs[0]))
ys = np.hstack((ys, ys[0]))
示例7: _graph_grid
# 需要導入模塊: from pychron.graph.graph import Graph [as 別名]
# 或者: from pychron.graph.graph.Graph import set_y_limits [as 別名]
def _graph_grid(self, x, y, z, ze, r, reg, refresh):
self.min_j = min(z)
self.max_j = max(z)
g = self.graph
layout = FigureLayout(fixed='square')
nrows, ncols = layout.calculate(len(x))
if not isinstance(g, Graph):
g = Graph(container_dict={'bgcolor': 'gray',
'kind': 'g',
'shape': (nrows, ncols)})
self.graph = g
def get_ip(xi, yi):
return next(
(ip for ip in self.monitor_positions if ((ip.x - xi) ** 2 + (ip.y - yi) ** 2) ** 0.5 < 0.01), None)
opt = self.plotter_options
monage = opt.monitor_age * 1e6
lk = opt.lambda_k
ans = self._analyses[0]
scale = opt.flux_scalar
for r in range(nrows):
for c in range(ncols):
idx = c + ncols * r
if refresh:
try:
yy = z[idx] * scale
ye = ze[idx] * scale
except IndexError:
continue
if hasattr(g, 'rules'):
l1, l2, l3 = g.rules[idx]
l1.value = yy
l2.value = yy + ye
l3.value = yy - ye
g.refresh()
else:
plot = g.new_plot(padding_left=65, padding_right=5, padding_top=30, padding_bottom=5)
try:
ip = get_ip(x[idx], y[idx])
except IndexError:
continue
add_axes_tools(g, plot)
yy = z[idx] * scale
ye = ze[idx] * scale
plot.title = 'Identifier={} Position={}'.format(ip.identifier, ip.hole_id)
plot.x_axis.visible = False
if c == 0 and r == nrows // 2:
plot.y_axis.title = 'J x{}'.format(scale)
if not ip.use:
continue
# get ip via x,y
ais = [a for a in ans if a.irradiation_position == ip.hole_id]
n = len(ais)
# plot mean value
l1 = g.add_horizontal_rule(yy, color='black', line_style='solid', plotid=idx)
l2 = g.add_horizontal_rule(yy + ye, plotid=idx)
l3 = g.add_horizontal_rule(yy - ye, plotid=idx)
if hasattr(g, 'rules'):
g.rules.append((l1, l2, l3))
else:
g.rules = [(l1, l2, l3)]
# plot individual analyses
fs = [a.model_j(monage, lk) * scale for a in ais]
fs = sorted(fs)
iys = array([nominal_value(fi) for fi in fs])
ies = array([std_dev(fi) for fi in fs])
s, _p = g.new_series(linspace(0, n - 1, n), iys, yerror=ies, type='scatter',
marker='circle', marker_size=3)
g.set_x_limits(0, n - 1, pad='0.1', plotid=idx)
g.set_y_limits(min(iys - ies), max(iys + ies), pad='0.1', plotid=idx)
ebo = ErrorBarOverlay(component=s, orientation='y')
s.underlays.append(ebo)
s.error_bars = ebo
add_analysis_inspector(s, ais)
s.index.on_trait_change(self._grid_update_graph_metadata(ais), 'metadata_changed')
self.suppress_metadata_change = True
sel = [i for i, a in enumerate(ais) if a.is_omitted()]
s.index.metadata['selections'] = sel
self.suppress_metadata_change = False
示例8: _graph_hole_vs_j
# 需要導入模塊: from pychron.graph.graph import Graph [as 別名]
# 或者: from pychron.graph.graph.Graph import set_y_limits [as 別名]
def _graph_hole_vs_j(self, x, y, r, reg, refresh):
sel = [i for i, (a, x, y, e) in enumerate(zip(*self._analyses)) if a.is_omitted()]
g = self.graph
if not isinstance(g, Graph):
g = Graph(container_dict={'bgcolor': self.plotter_options.bgcolor})
self.graph = g
po = self.plotter_options
is_matching = po.model_kind == 'Matching'
ys = reg.ys
xs = arctan2(x, y)
yserr = reg.yserr
lyy = ys - yserr
uyy = ys + yserr
a = max((abs(min(xs)), abs(max(xs))))
fxs = linspace(-a, a)
a = r * sin(fxs)
b = r * cos(fxs)
pts = vstack((a, b)).T
fys = reg.predict(pts)
if not is_matching:
try:
l, u = reg.calculate_error_envelope(fxs, rmodel=fys)
except BaseException:
l, u = reg.calculate_error_envelope(pts, rmodel=fys)
if not refresh:
g.clear()
p = g.new_plot(xtitle='Hole (Theta)',
ytitle='J',
# padding=[90, 5, 5, 40],
padding=po.paddings())
p.bgcolor = po.plot_bgcolor
add_axes_tools(g, p)
def label_fmt(xx):
return floatfmt(xx, n=2, s=4, use_scientific=True)
p.y_axis.tick_label_formatter = label_fmt
# plot fit line
# plot0 == line
if not is_matching:
line, _p = g.new_series(fxs, fys)
ee = ErrorEnvelopeOverlay(component=line,
xs=fxs, lower=l, upper=u)
line.error_envelope = ee
line.underlays.append(ee)
# plot the individual analyses
# plot1 == scatter
iscatter, iys = self._graph_individual_analyses()
# plot means
# plot2 == scatter
scatter, _ = g.new_series(xs, ys,
yerror=yserr,
type='scatter',
marker_size=4, marker='diamond')
ebo = ErrorBarOverlay(component=scatter,
orientation='y')
scatter.underlays.append(ebo)
scatter.error_bars = ebo
add_inspector(scatter, self._additional_info)
ymi = min(lyy.min(), min(iys))
yma = max(uyy.max(), max(iys))
g.set_x_limits(-3.5, 3.5)
g.set_y_limits(ymi, yma, pad='0.1')
# set metadata last because it will trigger a refresh
self.suppress_metadata_change = True
iscatter.index.metadata['selections'] = sel
self.suppress_metadata_change = False
# add a legend
if not is_matching:
labels = [('plot1', 'Individual'),
('plot2', 'Mean'),
('plot0', 'Fit'),
]
else:
labels = [('plot0', 'Individual'),
('plot1', 'Mean')]
legend = ExplicitLegend(plots=self.graph.plots[0].plots,
labels=labels)
p.overlays.append(legend)
else:
plot = g.plots[0]
#.........這裏部分代碼省略.........