本文整理汇总了Python中matplotlib.widgets.CheckButtons类的典型用法代码示例。如果您正苦于以下问题:Python CheckButtons类的具体用法?Python CheckButtons怎么用?Python CheckButtons使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CheckButtons类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _do_plot
def _do_plot(self):
stats = self._statistics.deserialize()
metrics_to_plot = self._statistics.get_metrics_to_plot()
subplots_count = len(stats)
if not subplots_count:
return
fig, axarr = plt.subplots(subplots_count)
fig.canvas.set_window_title(self._plot_title)
time = range(len(stats[stats.keys()[0]]))
axes_by_names = {}
for i, key in enumerate(stats.keys()):
axarr[i].plot(time, stats[key], label=metrics_to_plot[key].name, lw=1, color=COLORS[i])
axarr[i].set_xlabel('time (sec)')
axarr[i].set_ylabel(metrics_to_plot[key].unit.name)
axarr[i].legend()
axes_by_names[key] = i
rax = plt.axes([0.01, 0.8, 0.1, 0.1])
check_btns = CheckButtons(rax, stats.keys(), [True] * subplots_count)
check_btns.on_clicked(self._get_show_hide_fn(fig, axarr, axes_by_names))
plt.subplots_adjust(left=0.2)
plt.show()
开发者ID:Altoros,项目名称:plsar,代码行数:27,代码来源:plot_sar.py
示例2: plot_hmm_path
def plot_hmm_path(trajectory_objs, paths, legends=[], items=[]):
global colors
print_n_flush("Colors are:", colors)
for i, (trajectory, p) in enumerate(zip(trajectory_objs, paths)):
print_n_flush("Path:", p)
tr_colors = [colors[int(state)] for state in p]
t = trajectory.plot2d(color=tr_colors)
# t = plot_quiver2d(trajectory, color=tr_colors, path=p)
too_high = [tt for tt in trajectory if tt[1] > 400]
# print_n_flush( "Too high", too_high)
legends.append("Trajectory%i" % i)
# items.append(p)
items.append(t)
# gca().legend()
# Let's create checkboxes
rax = plt.axes([0.05, 0.4, 0.1, 0.15])
# rax = plt.gca()
from matplotlib.widgets import CheckButtons
check = CheckButtons(rax, legends, [True] * len(legends))
# plt.sca(axes)
def func(label):
widget = items[legends.index(label)]
widget.set_visible(not widget.get_visible())
plt.draw()
check.on_clicked(func)
开发者ID:keryil,项目名称:leaparticulatorqt,代码行数:31,代码来源:StreamlinedDataAnalysisGhmm.py
示例3: __click_cb
class PeakIdentifier:
def __click_cb(self, label):
self.all_names[label] = not self.all_names[label]
def __init_fig__(self, data_name):
self.fig = figure()
self.ax = subplot(111)
self.fig.subplots_adjust(left=0.3)
title(_path.basename(data_name))
self.button_ax = plt.axes([0.05, 0.1, 0.15, 0.8])
self.check = CheckButtons(self.button_ax, sorted(self.all_names.keys()), [False] * len(self.all_names))
self.check.on_clicked(self.__click_cb)
def __init_data__(self, data, start_i, end_i, pos, pos_s):
start_i = int(start_i)
end_i = int(end_i) + 1
self.start_i = start_i
self.end_i = end_i
self.__pos = pos
self.__pos_s = pos_s
self.d = end_i - start_i
new_start = start_i - 10 * self.d
if new_start < 0:
new_start = 0
new_end = end_i + 10 * self.d
if new_end >= len(data[2]):
new_end = len(data[2] - 1)
self.new_start = new_start
self.new_end = new_end
self.xs = r_[self.new_start : self.new_end]
y1 = data[2][new_start:new_end]
y2 = data[3][new_start:new_end]
self.y = y2 - y1
def __init_plot__(self):
self.ax.axvline(self.__pos, color="m", linewidth=2)
self.ax.axvline(self.__pos - self.__pos_s, color="g")
self.ax.axvline(self.__pos + self.__pos_s, color="g")
self.ax.plot(self.xs, self.y, color="c")
self.ax.set_ylim(min(self.y), max(self.y))
self.ax.set_xlim(self.new_start, self.new_end)
def __init_names__(self, names):
self.all_names = {}
for n in names:
self.all_names[n] = False
def __init__(self, names, data, start_i, end_i, data_name, pos, pos_s):
self.__init_names__(names)
self.__init_fig__(data_name)
self.__init_data__(data, start_i, end_i, pos, pos_s)
self.__init_plot__()
def run(self):
show()
close()
return [k for k, v in self.all_names.items() if v]
开发者ID:yuyichao,项目名称:jlab2s13,代码行数:59,代码来源:identify_peaks.py
示例4: plot
def plot(self, params, confidence_levels=[0.90, 0.95, 0.99], downsample=100):
from plotutils import plotutils as pu
from matplotlib import pyplot as plt
from matplotlib.widgets import CheckButtons
from itertools import cycle
lines = ['solid', 'dashed', 'dashdot', 'dotted']
linecycler = cycle(lines)
N = len(self._tracking_array)
tracking_array = self._tracking_array
param1 = tracking_array[params[0]]
param2 = tracking_array[params[1]]
pu.plot_greedy_kde_interval_2d(np.vstack([param1, param2]).T, [0.90,0.95,0.99])
ax = plt.gca()
arrows = {}
for proposal in self._proposals:
ls = next(linecycler)
sel = tracking_array['proposal'] == proposal
accepted = tracking_array['accepted'][sel]
xs = param1[sel]
ys = param2[sel]
x_ps = tracking_array[params[0]+'_p'][sel]
y_ps = tracking_array[params[1]+'_p'][sel]
dxs = x_ps - xs
dys = y_ps - ys
arrows[proposal] = []
for x, y, dx, dy, a in zip(xs,ys,dxs,dys,accepted):
if dx != 0 or dy != 0:
c = 'green' if a else 'red'
arrow = ax.arrow(x, y, dx, dy, fc=c, ec=c, alpha=0.5, visible=False, linestyle=ls)
arrows[proposal].append(arrow)
plt.subplots_adjust(left=0.5)
rax = plt.axes([0.05, 0.4, 0.4, 0.35])
check = CheckButtons(rax, self._proposals, [False for i in self._proposals])
def func(proposal):
N = len(arrows[proposal])
step = int(np.floor(N/float(downsample)))
step = step if step is not 0 else 1
for l in arrows[proposal][::step]:
l.set_visible(not l.get_visible())
plt.draw()
check.on_clicked(func)
plt.show()
开发者ID:farr,项目名称:nu-ligo-utils,代码行数:50,代码来源:proptracking.py
示例5: __init__
def __init__(self):
self.Consistency = 'Not self consistent'
self.Bias = 0.1
self.Gate = None
self.OrbitalSel = None
self.fig, (self.axBias, self.axTrans, self.axIVCurve) = plt.subplots(3,1)
self.fig.patch.set_facecolor('ghostwhite')
plt.subplots_adjust(left=0.3)
pos = self.axBias.get_position()
self.axBias.set_position ([pos.x0, 0.55, pos.width, 0.40])
self.axTrans.set_position([pos.x0, 0.05, pos.width, 0.40])
self.axIVCurve.set_position([0.05, 0.05, 0.2, 0.3])
self.axCM = self.fig.add_axes([0.94, 0.55, 0.01, 0.35])
self.fig.canvas.mpl_connect('button_press_event', self.OnClick)
self.fig.canvas.mpl_connect('pick_event', self.OnPick)
self.fig.canvas.mpl_connect('key_press_event', self.OnPress)
self.InitMolecule()
self.InitBias()
self.InitTrans()
self.InitOrbitals()
self.InitIVCurve()
self.axSC = plt.axes([0.05, 0.85, 0.15, 0.10], axisbg='white')
self.cbSC = RadioButtons(self.axSC, ('Not self consistent', 'Hubbard', 'PPP'))
self.cbSC.on_clicked(self.UpdateConsistency)
self.axOptions1 = plt.axes([0.05, 0.7, 0.15, 0.10], axisbg='white')
self.cbOptions1 = CheckButtons(self.axOptions1, ('Overlap', 'Show Local Density','Show Local Currents'), (False, False, True))
self.cbOptions1.on_clicked(self.Options1)
self.axOptions2 = plt.axes([0.05, 0.5, 0.15, 0.15], axisbg='white')
self.cbOptions2 = CheckButtons(self.axOptions2, ('Show Transmission', 'Show Current', 'Show DOS', 'Show Orbitals', 'Show Phase'), (True, True, False, False, False))
self.cbOptions2.on_clicked(self.Options2)
c = ['seagreen', 'b', 'darkorange', 'lightsteelblue', 'm']
[rec.set_facecolor(c[i]) for i, rec in enumerate(self.cbOptions2.rectangles)]
self.axGleft = plt.axes([0.05, 0.43, 0.15, 0.02], axisbg='white')
self.axGright = plt.axes([0.05, 0.40, 0.15, 0.02], axisbg='white')
self.sGleft = Slider(self.axGleft, 'Gl', 0.0, 1.0, valinit = gLeft)
self.sGright = Slider(self.axGright, 'Gr', 0.0, 1.0, valinit = gRight)
self.sGleft.on_changed(self.UpdateG)
self.sGright.on_changed(self.UpdateG)
self.axSave = plt.axes([0.92, 0.95, 0.07, 0.04])
self.bSave = Button(self.axSave, 'Save')
self.bSave.on_clicked(self.Save)
开发者ID:TimGebraad,项目名称:TN2953_Bachelor_EindProject,代码行数:48,代码来源:Graphics.py
示例6: __init__
def __init__(self, fig, rect, labels, act=None, func=None, fargs=None):
"""init function
Parameters:
fig: a matplotlib.figure.Figure instance
rect: [left, bottom, width, height]
each of which in 0-to-1-fraction i.e. 0<=x<=1
labels: array of strings
labels to be checked
act: a len(labels) array of booleans, optional, default: None
indicating whether the label is active at first
if None, all labels are inactive
func: function, optional, default: None
if not None, function called when checkbox status changes
fargs: array, optional, default: None
(optional) arguments for func
"""
self.fig = fig
self._rect = rect
self._func = func
self._fargs = fargs
self._labels = labels
self.axes = self.fig.add_axes(rect)
self.axes.set_axis_bgcolor('1.00')
inac = act if act is not None else (False,) * len(labels)
self.cb = CheckButtons(self.axes, self._labels, inac)
self.cb.on_clicked(self._onchange)
开发者ID:alesslazzari,项目名称:eledp,代码行数:27,代码来源:widg.py
示例7: init_ax4
def init_ax4():
global ax4, checkService, checkPause, checkEndBen, checkDist, check
ax4 = fig.add_axes([.72, .15, .08, .12])
ax4.set_xticklabels([])
ax4.set_yticklabels([])
ax4.set_xticks([])
ax4.set_yticks([])
# Define checkboxes
check = CheckButtons(ax4, ('Service', 'Stepped', 'Pause', 'EndBen', 'Dist'),
(checkService, checkStepped, checkPause, checkEndBen, checkDist))
# Attach checkboxes to checkbox function
check.on_clicked(func)
开发者ID:slehar,项目名称:service-prov,代码行数:16,代码来源:axes.py
示例8: __init_fig__
def __init_fig__(self, data_name):
self.fig = figure()
self.ax = subplot(111)
self.fig.subplots_adjust(left=0.3)
title(_path.basename(data_name))
self.button_ax = plt.axes([0.05, 0.1, 0.15, 0.8])
self.check = CheckButtons(self.button_ax, sorted(self.all_names.keys()), [False] * len(self.all_names))
self.check.on_clicked(self.__click_cb)
开发者ID:yuyichao,项目名称:jlab2s13,代码行数:8,代码来源:identify_peaks.py
示例9: initWindow
def initWindow(self):
if not (self.args.placeOne and self.args.placeTwo):
self.randomBB()
axes().set_aspect('equal', 'datalim')
plt.subplot(2, 2, (1, 2))
plt.subplot(2, 2, (1, 2)).set_aspect('equal')
subplots_adjust(left=0.31)
subplots_adjust(bottom=-0.7)
plt.title('QSR Visualisation')
axcolor = 'lightgoldenrodyellow'
rax = plt.axes([0.03, 0.4, 0.22, 0.45], axisbg=axcolor)
checkBox = CheckButtons(rax, self.qsr_type,(False,False,False,False,False))
checkBox.on_clicked(self.EventClick)
plt.subplot(2, 2, 3)
plt.axis('off')
plt.text(1, 1, (self.__compute_qsr(self.bb1, self.bb2)), family='serif', style='italic', ha='center')
if self.qsr:
self.updateWindow()
plt.show()
开发者ID:OMARI1988,项目名称:strands_qsr_lib,代码行数:19,代码来源:basic_qsr_visualiser.py
示例10: _init_checks
def _init_checks(self):
self.check_labels = []
self.check_display = []
for i in range(self.n):
fn = self.config['data'][i]['filename']
label = '%s' % (os.path.basename(fn))
self.check_labels.append(label)
self.check_display.append(self.mappables[i])
self.checks = CheckButtons(self.check_ax, self.check_labels, \
self.check_display)
开发者ID:ml4wc,项目名称:scurgen,代码行数:11,代码来源:plotting.py
示例11: __init__
def __init__(self, data, auto_mask, savedir):
'''The constructor initializes all the variables and creates the plotting window.
**Input arguments:**
- *data*: NxM array
The background to be masked - an averaged (static) scattering image.
- *auto_mask*: NxM array
The default mask, masking all the bad pixels.
- *savedir*: string
Directory where the mask file will be saved.
'''
self.mask_saved = False
self.savedir = savedir
self.fig = figure()
title('Select ROI to mask. Press m to mask or w to save and exit ')
self.ax = self.fig.add_subplot(111)
# Check button for logscale switching
self.cbax = self.fig.add_axes([0.01, 0.8, 0.1, 0.15])
self.cb_log = CheckButtons(self.cbax, ('log',), (False,))
self.cb_log.on_clicked(self.toggle_logscale)
self.log_flag = False
self.canvas = self.ax.figure.canvas
#self.data = n.log10(data)
self.raw_data = data.copy()
self.data = data
self.lx, self.ly = shape(self.data)
self.auto_mask = auto_mask
self.mask = auto_mask
self.masked_data = n.ma.masked_array(self.data,self.mask)
self.points = []
self.key = []
self.x = 0
self.y = 0
self.xy = []
self.xx = []
self.yy = []
self.ind = 0
self.img = self.ax.imshow(self.masked_data,origin='lower',interpolation='nearest',animated=True)
self.colorbar = colorbar(self.img,ax=self.ax)
self.lc,=self.ax.plot((0,0),(0,0),'-+w',color='black',linewidth=1.5,markersize=8,markeredgewidth=1.5)
self.lm,=self.ax.plot((0,0),(0,0),'-+w',color='black',linewidth=1.5,markersize=8,markeredgewidth=1.5)
self.ax.set_xlim(0,self.lx)
self.ax.set_ylim(0,self.ly)
for i in range(self.lx):
for j in range(self.ly):
self.points.append([i,j])
cidb = connect('button_press_event', self.on_click)
cidk = connect('key_press_event',self.on_click)
cidm = connect('motion_notify_event',self.on_move)
开发者ID:pawel-kw,项目名称:pyxsvs,代码行数:53,代码来源:makemask.py
示例12: __init__
def __init__(self, field, fieldname, halospec=None):
"""Initializes a visualization instance, that is a windows with a field
field is a 3D numpy array
fieldname is a string with the name of the field
halospec is a 2x2 array with the definition of the halo size
After this call the window is shown
"""
self.field = field
self.fieldname = fieldname
# Register halo information
if halospec is None:
halospec = [[3, 3], [3, 3]]
self.istart = halospec[0][0]
self.iend = field.shape[0] - halospec[0][1]
self.jstart = halospec[1][0]
self.jend = field.shape[1] - halospec[1][1]
self.plotHalo = True
self.plotLogLog = False
self.curklevel = 0
self.figure = plt.figure()
# Slider
slideraxes = plt.axes([0.15, 0.02, 0.5, 0.03], axisbg="lightgoldenrodyellow")
self.slider = Slider(slideraxes, "K level", 0, field.shape[2] - 1, valinit=0)
self.slider.valfmt = "%2d"
self.slider.set_val(0)
self.slider.on_changed(self.updateSlider)
# CheckButton
self.cbaxes = plt.axes([0.8, -0.04, 0.12, 0.15])
self.cbaxes.set_axis_off()
self.cb = CheckButtons(self.cbaxes, ("Halo", "Logscale"), (self.plotHalo, self.plotLogLog))
self.cb.on_clicked(self.updateButton)
# Initial plot
self.fieldaxes = self.figure.add_axes([0.1, 0.15, 0.9, 0.75])
self.collection = plt.pcolor(self._getField(), axes=self.fieldaxes)
self.colorbar = plt.colorbar()
self.fieldaxes.set_xlim(right=self._getField().shape[1])
self.fieldaxes.set_ylim(top=self._getField().shape[0])
plt.xlabel("i")
plt.ylabel("j")
self.title = plt.title("%s - Level 0" % (fieldname,))
plt.show(block=False)
开发者ID:PallasKat,项目名称:serial_box,代码行数:49,代码来源:Visualizer.py
示例13: _recreate_show_lines_check_button
def _recreate_show_lines_check_button(self):
axcolor = "lightgoldenrodyellow"
if hasattr(self, "rax_showlines"):
self.rax_showlines.cla()
self.rax_showlines = plt.axes([0.2, 0.05, self.button_length__, self.button_height__], axisbg=axcolor)
visible = self.prop_ifs.holder.get_visible()
linestyle = self.prop_ifs.holder.get_linestyle()
labels = ("hide ifs", "markers", "edges", "labels")
actives = (self.prop_ifs.hide_ifs, visible, linestyle not in ["None", None], self.prop_ifs.show_ann)
self.holder_actives = dict(zip(labels, actives))
self.w_check_components = CheckButtons(self.rax_showlines, labels, actives)
self.w_check_components.on_clicked(self.update_show_components)
return self.w_check_components
开发者ID:jubi-ifs,项目名称:ifs-lattice,代码行数:19,代码来源:widgets_basic.py
示例14: _recreate_show_lines_check_button
def _recreate_show_lines_check_button(self):
if self.ax_active not in self.active_lines_idx.keys():
return None
axcolor = 'lightgoldenrodyellow'
if hasattr(self, 'rax_showlines'):
self.rax_showlines.cla()
self.rax_showlines = plt.axes([0.2, 0.05,
self.button_length__,
self.button_height__], axisbg=axcolor)
prop_ifs = self._prop_idx_active[self.line_active__]
visible = prop_ifs.holder.get_visible()
linestyle = prop_ifs.holder.get_linestyle()
self.w_check_components = CheckButtons(self.rax_showlines,
('markers', 'edges', 'labels'),
(visible, linestyle not in ['None', None], prop_ifs.show_ann))
self.w_check_components.on_clicked(self.update_show_components)
return self.w_check_components
开发者ID:jubi-ifs,项目名称:ifs-lattice,代码行数:19,代码来源:test_interactive_line.py
示例15: __init__
def __init__(self):
self.data = 0
self.errors = 0
self.tBins = 0
self.fig = plt.figure(1)
self.ax = self.fig.add_subplot(111,title="Pulse Display")
self.fig.subplots_adjust(left=0.3)
self.numPulse = 1
self.flcFlag = False
self.timeOffset = 0.0
self.currentModelName=[]
self.tMaxSelector = 0
self.resultAx =False
self.useSelector = False
#check if a pulseModSelector has been passed
self.pms = False
self.radio = False
ax = plt.axes([.05, 0.05, 0.12, 0.08])
self.addButton = Button(ax,'Add Pulse',color='0.95', hovercolor='0.45')
self.addButton.on_clicked(self.AddPulse)
ax2 = plt.axes([.05, 0.15, 0.12, 0.08])
self.findMaxButton = Button(ax2,'Find Max',color='0.95', hovercolor='0.45')
self.findMaxButton.on_clicked(self.FindMax)
ax3 = plt.axes([.05, 0.25, 0.12, 0.08])
self.fitButton = Button(ax3,'Fit',color='0.95', hovercolor='0.45')
self.fitButton.on_clicked(self.FitPulse)
ax4 = plt.axes([.05, 0.45, 0.12, 0.08])
self.useSelectorCheck = CheckButtons(ax4, ["Selector"], [False] )
self.useSelectorCheck.on_clicked(self.UseSelector)
开发者ID:JohannesBuchner,项目名称:spectralTools,代码行数:41,代码来源:pulseFit.py
示例16: __init__
def __init__(self, ax, collection, rax, raxmap, labels, labelcolors):
self.canvas = ax.figure.canvas
self.collection = collection
self.labelcolors = [colorConverter.to_rgba(c) for c in labelcolors]
self.labels = labels
self.xys = collection.get_offsets()
self.Npts = len(self.xys)
# Ensure that we have separate colors for each object
self.fc = collection.get_facecolors()
if len(self.fc) == 0:
raise ValueError('Collection must have a facecolor')
elif len(self.fc) == 1:
self.fc = np.tile(self.fc, self.Npts).reshape(self.Npts, -1)
self.sfc = self.fc.copy()
self.state = [False] * len(labels)
self.check = CheckButtons(rax,labels,self.state)
self.check.on_clicked(self.onclick)
self.raxmap = raxmap
self.ind = []
开发者ID:georgedimitriadis,项目名称:themeaningofbrain,代码行数:22,代码来源:attributeselector.py
示例17: plot_clusters_in_brain
def plot_clusters_in_brain(bn,background,cluster_list,actives=[True,False,False]):
if len(cluster_list)<3:
print 'just '+str(len(cluster_list))+ ' cluster'
colors=[[1,0,0],[0,1,0],[0,0,1]]
node2voxel=bn.get_node2voxel()
img=nib.load(bn.mask)
imgB = nib.load(background)
D=img.get_data()
sh=D.shape
A=bn.affine
aspect1=abs(A[2,2]/A[0,0])
aspect2=abs(A[2,2]/A[1,1])
aspect3=abs(A[1,1]/A[0,0])
M=pylab.zeros((sh[0],sh[1],sh[2],3))
B=M
B0=imgB.get_data().astype(numpy.float32, copy=False)
#B0img.get_data().astype(numpy.float32, copy=False)
B[:,:,:,0]=(B0-B0.min())/(B0.max()-B0.min())
B[:,:,:,1]=B[:,:,:,0]
B[:,:,:,2]=B[:,:,:,0]
M=B
#M[D>0,:]=pylab.ones_like(M[D>0,:])
for ii in range(len(actives)):
if actives[ii]:
if len(cluster_list)>ii:
for node in cluster_list[ii]:
(i,j,k)=node2voxel[str(node)]
M[i,j,k,:]=[B[i,j,k,l]*colors[ii][l] for l in range(3)]
plt.figure()
plt.subplot(221)
j0 = round(M.shape[1]*0.5)
lj = plt.imshow(M[:,j0,:,:].swapaxes(0,1),interpolation='None',aspect=aspect1)
plt.axis([0, sh[0], 0, sh[2]])
plt.subplot(222)
i0 = round(M.shape[0]*0.5)
li = plt.imshow(M[i0,:,:,:].swapaxes(0,1),interpolation='None',aspect=aspect2)
plt.axis([0, sh[1], 0, sh[2]])
plt.subplot(223)
k0 = round(M.shape[2]*0.5)
lk = plt.imshow(M[:,:,k0,:].swapaxes(0,1),interpolation='None',aspect=aspect3)
plt.axis([0, sh[0], 0, sh[1]])
axcolor = 'lightgoldenrodyellow'
axi = plt.axes([0.55, 0.3, 0.4, 0.03], axisbg=axcolor)
axj = plt.axes([0.55, 0.2, 0.4, 0.03], axisbg=axcolor)
axk = plt.axes([0.55, 0.1, 0.4, 0.03], axisbg=axcolor)
si = Slider(axi, 'i', 0, sh[0]-1, valinit=i0,valfmt='%i')
sj = Slider(axj, 'j', 0, sh[1]-1, valinit=j0,valfmt='%i')
sk = Slider(axk, 'k', 0, sh[2]-1, valinit=k0,valfmt='%i')
def update(val):
i = int(si.val)
j = int(sj.val)
k = int(sk.val)
lj.set_data(M[:,j,:,:].swapaxes(0,1))
li.set_data(M[i,:,:,:].swapaxes(0,1))
lk.set_data(M[:,:,k,:].swapaxes(0,1))
plt.draw()
si.on_changed(update)
sj.on_changed(update)
sk.on_changed(update)
rax = plt.axes([0.025, 0.5, 0.1, 0.15], axisbg=axcolor)
check = CheckButtons(rax, ('0', '1', '2'), actives=actives)
def showcluster(label):
i0=int(si.val)
j0=int(sj.val)
k0=int(sk.val)
M=B
for node in cluster_list[int(label)]:
(i,j,k)=node2voxel[str(node)]
if all(M[i,j,k,:]==colors[int(label)]):
M[i,j,k,:]=[1,1,1]
else:
M[i,j,k,:]=colors[int(label)]
lj.set_data(M[:,j0,:,:].swapaxes(0,1))
li.set_data(M[i0,:,:,:].swapaxes(0,1))
lk.set_data(M[:,:,k0,:].swapaxes(0,1))
plt.draw()
check.on_clicked(showcluster)
return
开发者ID:ababino,项目名称:networkb,代码行数:79,代码来源:plot_clusters_in_brain.py
示例18: initialize
#.........这里部分代码省略.........
t.append(float(x[0])-0.0001)
t.append(x[0])
t.append(float(x[0])+0.0001)
for y in picked_list:
if x[2]==y[1] and x[3]==y[2]:
s_b.append(0.0)
s_b.append(str(10**float(x[1])))
s_b.append(0.0)
t_b.append(float(x[0])-0.0001)
t_b.append(x[0])
t_b.append(float(x[0])+0.0001)
ax = figure_h.add_subplot(212)
plt.subplots_adjust(left=0.25, bottom=0.25)
pl.subplots_adjust( hspace=0.0,right=0.97 )
a0 = 5
f0 = 3
global l,triples_plt
l, = plt.plot(t,s, lw=2, color='red')
triples_plt, = plt.plot([],[], '*',markersize=15,color='blue')
ax.set_xlim([f_lower_g,f_upper_g])
global picked_plt, ax2
picked_plt, = plt.plot(t_b,s_b,lw=2,color='black')
#plt.axis([0, 1, -10, 10])
#figure_h.canvas.mpl_connect('button_press_event', handle_mouse_press)
ax2 = figure_h.add_subplot(211,sharex=ax)
ax2.axes.get_xaxis().set_visible(False)
global peak_list_plt,exp_plt,trans_1_plt,trans_2_plt,trans_3_plt
peak_list_plt, = ax2.plot([],[],'o',color='red')
trans_1_plt, = ax2.plot([],[],'s',color='cyan')
trans_2_plt, = ax2.plot([],[],'s',color='magenta')
trans_3_plt, = ax2.plot([],[],'s',color='yellow')
ax2.set_xlim([f_lower_g,f_upper_g])
global locator
locator = ax2.yaxis.get_major_locator()
exp_plt, = ax2.plot([],[],lw=2,color='black')
global peak_1_uncertainty,peak_2_uncertainty,peak_3_uncertainty,peaklist,freq_low,freq_high
figure_h.canvas.mpl_connect('key_press_event', on_key)
axcolor = 'lightgoldenrodyellow'
axA = plt.axes([0.25, 0.15, 0.65, 0.03], axisbg=axcolor)
axB = plt.axes([0.25, 0.1, 0.65, 0.03], axisbg=axcolor)
axC = plt.axes([0.25, 0.05, 0.65, 0.03], axisbg=axcolor)
axua = plt.axes([0.03, 0.22, 0.1, 0.03], axisbg=axcolor)
axub = plt.axes([0.03, 0.17, 0.1, 0.03], axisbg=axcolor)
axuc = plt.axes([0.03, 0.12, 0.1, 0.03], axisbg=axcolor)
#axub = plt.axes([0.25, 0.1, 0.65, 0.03], axisbg=axcolor)
#axuc = plt.axes([0.25, 0.05, 0.65, 0.03], axisbg=axcolor)
global ua_slider
ua_slider = Slider(axua, 'mu a', ua_g-1, ua_g+1, valinit=ua_g)
ua_slider.on_changed(update)
global ub_slider
ub_slider = Slider(axub, 'mu b', ub_g-1, ub_g+1, valinit=ub_g)
ub_slider.on_changed(update)
global uc_slider
uc_slider = Slider(axuc, 'mu c', uc_g-1, uc_g+1, valinit=uc_g)
uc_slider.on_changed(update)
global A_slider
global B_slider
global C_slider
global rax
rax = plt.axes([0.0, 0.5, 0.19, 0.4])
global check
check = CheckButtons(rax, ('','','',''), (True, False, False,False))
check.on_clicked(func)
A_slider = Slider(axA, 'A', A-dA, A+dA, valinit=A)
B_slider = Slider(axB, 'B', B-dB, B+dB, valinit=B)
C_slider = Slider(axC, 'C', C-dC, C+dC, valinit=C)
A_slider.on_changed(update)
B_slider.on_changed(update)
C_slider.on_changed(update)
global button
global radio
resetax = plt.axes([0.1, 0.025, 0.1, 0.04])
button = Button(resetax, 'Reset Sliders', color=axcolor, hovercolor='0.975')
button.on_clicked(reset)
#rax = plt.axes([0.025, 0.5, 0.15, 0.15], axisbg=axcolor)
#radio = RadioButtons(rax, ('red', 'blue', 'green'), active=0)
#radio.on_clicked(colorfunc)
global text_box
#global text_box2
text_box = plt.text(-1,8, "")
text_box2 = plt.text(-1,23, "Refine Mouse Selection: Select transitions by pushing 'q' and then clicking in the predicted spectrum ")
开发者ID:jldmv,项目名称:bband_scripts,代码行数:101,代码来源:fitting_GUI_B_v10.py
示例19: CBox
class CBox(object):
"""Custom checkbox."""
def __init__(self, fig, rect, labels, act=None, func=None, fargs=None):
"""init function
Parameters:
fig: a matplotlib.figure.Figure instance
rect: [left, bottom, width, height]
each of which in 0-to-1-fraction i.e. 0<=x<=1
labels: array of strings
labels to be checked
act: a len(labels) array of booleans, optional, default: None
indicating whether the label is active at first
if None, all labels are inactive
func: function, optional, default: None
if not None, function called when checkbox status changes
fargs: array, optional, default: None
(optional) arguments for func
"""
self.fig = fig
self._rect = rect
self._func = func
self._fargs = fargs
self._labels = labels
self.axes = self.fig.add_axes(rect)
self.axes.set_axis_bgcolor('1.00')
inac = act if act is not None else (False,) * len(labels)
self.cb = CheckButtons(self.axes, self._labels, inac)
self.cb.on_clicked(self._onchange)
def _onchange(self,label):
"""Actual function called when checkbox status changes."""
if self.get_visible():
if self._func is not None:
if self._fargs is not None:
self._func(*self._fargs)
else:
self._func()
self.fig.canvas.draw()
def get_status(self):
"""Get checkbox status.
Returns: status
status: list of booleans
a len(labels) list of booleans indicating whether
label is active
NB: checkbox status changes even when it's not visible
if a click hits the checkbox!
"""
stat = []
for i in self.cb.lines:
stat.append(i[0].get_visible() or i[1].get_visible())
return stat
def set_visible(self,b):
"""Set its visibility.
Parameters:
b: boolean
"""
self.axes.set_visible(b)
def get_visible(self):
"""Get its visibility.
Returns: b
b: boolean
"""
return self.axes.get_visible()
开发者ID:alesslazzari,项目名称:eledp,代码行数:72,代码来源:widg.py
示例20: RadioButtons
color='orange', hovercolor='orange')
bmark.on_clicked(callback.mark)
axcolor = 'lightgoldenrodyellow'
rb1_axes = plt.axes([0.70, 0.62, 0.10, 0.15], axisbg=axcolor)
radio1 = RadioButtons(rb1_axes, ('A', 'B', 'C'))
def rb_1(label):
print 'radio button 1'
radio1.on_clicked(rb_1)
rax = plt.axes([0.70, 0.3, 0.2, 0.25])
labels=['Type 1','Type 2', 'Type 4', 'Other']
check = CheckButtons(rax, (labels[0], labels[1], labels[2], labels[3]),
(False, False, False, False))
def func(label):
if label == labels[0]: check_text=labels[0]
elif label == labels[1]: check_text=labels[1]
elif label == labels[2]: check_text=labels[2]
elif label == labels[3]: check_text=labels[3]
print 'checked: ', check_text
check.on_clicked(func)
ax.text=(0.9, 0.9, 'ax.text 0.5')
fig.text=(0.9, 0.9, 'fig.text 0.5')
plt.show()
开发者ID:richardgmcmahon,项目名称:matplotlib_examples,代码行数:32,代码来源:gui_buttons_slider.py
注:本文中的matplotlib.widgets.CheckButtons类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论