本文整理汇总了Python中matplotlib.widgets.Button类的典型用法代码示例。如果您正苦于以下问题:Python Button类的具体用法?Python Button怎么用?Python Button使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Button类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: ButtonClickProcessor
class ButtonClickProcessor(object):
def __init__(self, axes, label, color, viewer):
self.groups = viewer.groups
self.fig_text = viewer.fig_text
self.button = Button(axes, label=label, color=color)
self.button.on_clicked(self.print_group)
def print_group(self, event):
print(self.button.label.get_text())
group = self.groups[int(self.button.label.get_text())]
self.fig_text.clf()
self.ax_text = self.fig_text.add_subplot(111)
# plt.rcParams['text.usetex'] = True
y_write = np.linspace(0, 0.9, len(group.keys()))
for ii, key in enumerate(group.keys()):
self.ax_text.text(0, y_write[ii], str(key) + ' : ' + str(group[key]), fontsize=15, fontstyle='oblique')
#Show it
self.fig_text.canvas.draw()
开发者ID:AminKhribi,项目名称:matplotlib_visual,代码行数:25,代码来源:visual.py
示例2: __init__
def __init__(self):
'''variable definitions'''
SEGMENTS = int(3) #number of segments
#could probably make these lists instead of arrays
self.l = np.array([0, 100, 100, 80])# actual measurements of segment length in mm
self.w = np.array([0]*SEGMENTS,dtype=float) #horizontal coordinate
self.z = np.array([0]*SEGMENTS,dtype=float) #vertical coordinate
self.x = np.array([0]*SEGMENTS,dtype=float) #x axis components
self.y = np.array([0]*SEGMENTS,dtype=float) #y axis components
self.a = np.array([np.pi]*SEGMENTS,dtype=float) #angle for the link, reference is previous link
self.gripper_angle = np.array([0, -45, -90, 45, 90])#preselected gripper angles
self.current_gripper = 2 #gripper angle selection
self.tw = 30.0 # w axis position depth
self.tz = 20.0 # z axis starting position height
self.l12 = 0.0 # hypotenuse belween a1 & a2
self.a12 = 0.0 #inscribed angle between hypotenuse, w
self.fig = plt.figure("CS 4TE3 Robot Simulator") #create the frame
self.ax = plt.axes([0.05, 0.2, 0.90, .75], projection='3d') #3d ax panel
self.axe = plt.axes([0.25, 0.85, 0.001, .001])#panel for error message
self.count = 0
self.coords = ((20,30),(50,60),(30,40),(70,100),(70,150))
self.display_error()
self.draw_robot()
butval = plt.axes([0.35, 0.1, 0.1, 0.075])
but = Button(butval, 'move')
but.on_clicked(self.move_click)
#error = dist(1,2);
#print (error)
plt.show()#end of constructor
开发者ID:ferrara,项目名称:RobotArm,代码行数:32,代码来源:robotarm.py
示例3: preparePlot
def preparePlot(shapeModeler):
global sliders, mainPlot, fig
fig, ax = plt.subplots();
whiteSpace = 0.15 + numParams*0.05;
plt.subplots_adjust( bottom=whiteSpace);
plt.axis('equal');
#plot of initial shape
params = np.zeros((numParams,1));
shape = shapeModeler.makeShape(params);
shape = ShapeModeler.normaliseShape(shape);
numPointsInShape = len(shape)/2;
x_shape = shape[0:numPointsInShape];
y_shape = shape[numPointsInShape:];
mainPlot, = plt.plot(x_shape, -y_shape);
plt.axis([-1, 1, -1, 1],autoscale_on=False, aspect='equal');
#add sliders to modify parameter values
parameterVariances = shapeModeler.getParameterVariances();
sliders = [0]*numParams;
for i in range(numParams):
slider = Slider(plt.axes([0.25, 0.1+0.05*(numParams-i-1), 0.65, 0.03], axisbg=axcolor),
'Parameter '+str(i+1), -5*parameterVariances[i], 5*parameterVariances[i], valinit=0);
slider.on_changed(update);
sliders[i] = slider;
resetax = plt.axes([0.8, 0.025, 0.1, 0.04])
button = Button(resetax, 'Reset', color=axcolor, hovercolor='0.975')
button.on_clicked(reset)
plt.show()
开发者ID:dhood,项目名称:shape_learning,代码行数:31,代码来源:shape_model_gui.py
示例4: __init__
def __init__(self, title, instances, quadrants, clusters):
self.title = title
self.instances = instances
self.quadrants = quadrants
self.clusters = clusters
self.overlay = False
self.trend = False
self.fig = plt.figure()
# Button axes
self.axtrends = self.fig.add_axes([0.75, 0.4, 0.2, 0.05])
self.btrends = Button(self.axtrends, 'Trends')
self.btrends.on_clicked(self.trends)
self.axalerts = self.fig.add_axes([0.75, 0.3, 0.2, 0.05])
self.balerts = Button(self.axalerts, 'Alerts')
self.balerts.on_clicked(self.alerts)
self.axoverlays = self.fig.add_axes([0.75, 0.2, 0.2, 0.05])
self.boverlays = Button(self.axoverlays, 'Overlays')
self.boverlays.on_clicked(self.overlays)
# Axes are defined [left, bottom, width, height]
self.canvas = self.fig.add_axes([0.1, 0.1, 0.6, 0.8])
self.draw_canvas_instances()
self.draw_canvas_quadrants_vanilla()
self.info = self.fig.add_axes([0.75, 0.5, 0.2, 0.4])
plt.setp(self.info, xticks=[], yticks=[])
cid = self.fig.canvas.mpl_connect('button_press_event', self.onclick)
开发者ID:abutcher,项目名称:bi,代码行数:33,代码来源:widget.py
示例5: __init__
def __init__(self, px, mx, kx):
self.buttonP = Button(px, '+')
self.buttonM = Button(mx, '-')
self.stVal = kx
self.buttonP.on_clicked(self.button_handler_p)
self.buttonM.on_clicked(self.button_handler_m)
开发者ID:UCSC-iGEM-2016,项目名称:taris_controller,代码行数:7,代码来源:taris_calibrate.py
示例6: debug_plot
def debug_plot(a, b, nodes, fs, coeffs):
global _debug_fig, _debug_cancelled
if _debug_cancelled:
return
if 'show' not in locals():
from pylab import axes, subplot, subplots_adjust, figure, draw, plot, axvline, xlim, title, waitforbuttonpress, gcf
from matplotlib.widgets import Button
if _debug_fig is None:
#curfig = gcf()
#print dir(curfig)
_debug_fig = figure()
ax = _debug_fig.add_subplot(111)
#subplots_adjust(bottom=0.15)
butax = axes([0.8, 0.015, 0.1, 0.04])
button = Button(butax, 'Debug', hovercolor='0.975')
def debug(event):
import pdb; pdb.set_trace()
button.on_clicked(debug)
_debug_fig.sca(ax)
draw()
#figure(curfig)
_debug_fig.gca().clear()
plot(nodes, fs, linewidth=5, figure = _debug_fig)
axvline(a, color="r", figure = _debug_fig)
axvline(b, color="r", figure = _debug_fig)
d = 0.05 * (b-a)
_debug_fig.gca().set_xlim(a-d, b+d)
title("press key in figure for next debugplot or close window to continue")
try:
while not _debug_cancelled and not _debug_fig.waitforbuttonpress(-1):
pass
except:
_debug_cancelled = True
开发者ID:ianmtaylor1,项目名称:pacal,代码行数:33,代码来源:utils.py
示例7: __init__
def __init__(self,image,points,imginfo={},fnext=None,verbosity=0):
"""
image ... 2D Array for background image
points ... initial list of peak positions shape(N,2)
imginfo... (opt) dictionary with image parameters (see ImageBrowser)
self.bDual.on_clicked(self.Dual);
verbosity. (opt) quiet (0), verbose (3), debug (4)
"""
# init ImageBrowser
super(PointBrowser,self).__init__(image,imginfo,fnext,verbosity);
self.axis.set_title('PointBrowser: %s' % self.imginfo['desc']);
# draw point list
self.points = np.asarray(points);
assert( self.points.ndim==2 and self.points.shape[1]==2 );
self.Line2D, = self.axis.plot(self.points[:,0], self.points[:,1],\
'ro',picker=5);
#self.axis.set_xlim(*self.imginfo['extent'][0:2]);
#self.axis.set_ylim(*self.imginfo['extent'][2:4]);
# add buttons
axEdit = self.fig.add_axes([0.85, 0.85,0.1, 0.04]);
axSave = self.fig.add_axes([0.85, 0.8, 0.1, 0.04]);
axLoad = self.fig.add_axes([0.85, 0.75,0.1, 0.04]);
self.bEdit = Button(axEdit,'Edit');
self.bSave = Button(axSave,'Save');
self.bLoad = Button(axLoad,'Load');
self.bEdit.on_clicked(self.ToggleEdit);
self.bSave.on_clicked(self.Save);
self.bLoad.on_clicked(self.Load);
self._update();
开发者ID:rhambach,项目名称:TEMimage,代码行数:33,代码来源:point_browser.py
示例8: __init__
class NavField:
def __init__(self, pltinfo):
self.fld = -1
self.nflds = len(pltinfo.selindices['field'])
self.pltinfo = pltinfo
prevwidth = 0.13
nextwidth = 0.12
butheight = 0.05
butleft = 0.7
butbot = 0.025
butgap = 0.5 * butbot
self.nextloc = [butleft + prevwidth + butgap,
butbot, nextwidth, butheight]
self.prevloc = [butleft, butbot, prevwidth, butheight]
self.inactivecolor = '#99aaff'
self.activecolor = '#aaffcc'
def _draw_buts(self):
if self.fld < self.nflds - 1:
axnext = pl.axes(self.nextloc)
self.bnext = Button(axnext, 'Next fld >',
color=self.inactivecolor,
hovercolor=self.activecolor)
self.bnext.on_clicked(self.next)
if self.fld > 0:
axprev = pl.axes(self.prevloc)
self.bprev = Button(axprev, '< Prev fld',
color=self.inactivecolor,
hovercolor=self.activecolor)
self.bprev.on_clicked(self.prev)
#pl.show()
def _do_plot(self):
didplot = plotfield(self.pltinfo.selindices['field'][self.fld],
self.pltinfo)
if didplot:
self._draw_buts()
return didplot
def next(self, event):
didplot = False
startfld = self.fld
while self.fld < self.nflds - 1 and not didplot:
self.fld += 1
didplot = self._do_plot()
if not didplot:
print "You are on the last field with any selected baselines."
self.fld = startfld
#plotfield(self.pltinfo.selindices['field'][self.fld],
# self.pltinfo, self.mytb)
def prev(self, event):
didplot = False
startfld = self.fld
while self.fld > 0 and not didplot:
self.fld -= 1
didplot = self._do_plot()
if not didplot:
print "You are on the first field with any selected baselines."
self.fld = startfld
开发者ID:keflavich,项目名称:casa,代码行数:60,代码来源:task_plotuv.py
示例9: _setup_display
def _setup_display(self):
"""
Sets up the Matplotlib figures and axes required for the visualization.
"""
self.network_fig = figure(figsize=(20, 20))
self.network_fig.canvas.set_window_title("Hopfield Network Visualization")
gs = gridspec.GridSpec(2, 4)
self.main_network = subplot(gs[:,:2])
self.main_network.set_title("Network Diagram")
self.main_network.get_xaxis().set_ticks([])
self.main_network.get_yaxis().set_ticks([])
self.energy_diagram = subplot(gs[0,2], projection='Fovea3D')
self.energy_diagram.set_title("Energy Function")
self.contour_diagram = subplot(gs[0,3])
self.contour_diagram.set_title("Energy Contours")
self.state_diagram = subplot(gs[1,2])
self.state_diagram.set_title("Current Network State")
self.state_diagram.get_xaxis().set_ticks([])
self.state_diagram.get_yaxis().set_ticks([])
self.weight_diagram = subplot(gs[1,3])
self.weight_diagram.set_title("Weight Matrix Diagram")
self.weight_diagram.get_xaxis().set_ticks([])
self.weight_diagram.get_yaxis().set_ticks([])
self.network_fig.suptitle("Hopfield Network Visualization", fontsize=14)
self.mode = self.network_fig.text(0.4, 0.95, "Current Mode: Initialization",
fontsize=14, horizontalalignment='center')
self.iteration = self.network_fig.text(0.6, 0.95, "Current Iteration: 0",
fontsize=14, horizontalalignment='center')
# Widget Functionality
view_wf = axes([.53, 0.91, 0.08, 0.025])
self.view_wfbutton = Button(view_wf, 'Wireframe')
view_attract = axes([.615, 0.91, 0.08, 0.025])
self.view_attractbutton = Button(view_attract, 'Attractors')
开发者ID:mcneela,项目名称:Retina,代码行数:34,代码来源:visuals.py
示例10: main
def main():
from matplotlib import pyplot as plt
import utils
fig = utils.createfig()
a = WSin(fig, [0.1, 0.5, 0.8, 0.3] , nps=5)
b = WSin(fig, [0.1, 0.1, 0.8, 0.3], nps=3, om=3)
args11 = (dict(k=0, am=1, ph=0, t='v', n='1'),
dict(k=-1.5, am=0.1, ph=0.5, t='v', n='3'),)
args12 = (dict(k=1,am=2,ph=1,t='i',n='2'),)
args13 = (dict(k=100,am=3,ph=2,t='i',n='no',v=False),)
args2 = (dict(k=0,am=1,ph=0,t='v',n='1'),dict(k=1,am=2,ph=1,t='i',n='2'),
dict(k=-1.5,am=0.1,ph=0,t='v',n='3'),\
dict(k=100,am=3,ph=2,t='i',n='no',v=False),)
a.new(100, args11, args12, ())
b.new(101, *args2)
#b.set_anim(True)
# bottone
from matplotlib.widgets import Button
box = fig.add_axes([0.05, 0.90, 0.05, 0.05])
but = Button(box, 'next')
def func(wtf):
#args2 = _r_args(4)
#print args2
#b.new(100, *args2)
b.set_anim(not b.get_anim())
but.on_clicked(func)
plt.show()
开发者ID:alesslazzari,项目名称:eledp,代码行数:32,代码来源:wsin_b.py
示例11: _init_ui
def _init_ui(self):
self.click_ev = self.fig.canvas.mpl_connect('button_press_event',
self._onclick)
self.motion_ev = self.fig.canvas.mpl_connect('motion_notify_event',
self._onmotion)
self.release_ev = self.fig.canvas.mpl_connect('button_release_event',
self._onrelease)
ax_load_img = self.fig.add_subplot(self.gs[1,:])
ax_load = self.fig.add_subplot(self.gs[2,0])
ax_save = self.fig.add_subplot(self.gs[2,1])
ax_reset = self.fig.add_subplot(self.gs[2,2])
self.fig.add_subplot(ax_load_img)
self.fig.add_subplot(ax_load)
self.fig.add_subplot(ax_save)
self.fig.add_subplot(ax_reset)
self._load_img_button = Button(ax_load_img, 'Load image')
self._load_img_button.on_clicked(self._on_load_image)
self._load_button = Button(ax_load, 'Load LMs')
self._load_button.on_clicked(self._on_load_landmarks)
self._save_button = Button(ax_save, 'Save LMs')
self._save_button.on_clicked(self._on_save_landmarks)
self._reset_button = Button(ax_reset, 'Reset LMs')
self._reset_button.on_clicked(self._on_reset_landmarks)
开发者ID:btel,项目名称:imageregistration,代码行数:29,代码来源:img_tool.py
示例12: initUI
def initUI(self):
self.fig, self.ax = plt.subplots()
self.fig.canvas.set_window_title('Numerik DGL 2 - Schattenprojektion')
self.fig.suptitle('Vorwaertsproblem')
plt.subplots_adjust(bottom=0.3)
plt.axis([0, 200, -100, 100])
plt.axis('equal')
axColor = 'lightgoldenrodyellow'
# Slider - Phi
axPhi = plt.axes([0.18, 0.2, 0.65, 0.03], axisbg=axColor)
self.sliderPhi = Slider(axPhi, 'Phi', 0, 360, valinit=self.phi, valfmt='%1d')
self.sliderPhi.on_changed(self.onUpdate)
# Slider - Delta Phi
axDeltaPhi = plt.axes([0.18, 0.15, 0.65, 0.03], axisbg=axColor)
self.sliderDeltaPhi = Slider(axDeltaPhi, 'Delta Phi', 5, 360, valinit=self.delta_phi, valfmt='%1d')
self.sliderDeltaPhi.on_changed(self.onUpdate)
# Slider - Psi
axPsi = plt.axes([0.18, 0.1, 0.65, 0.03], axisbg=axColor)
self.sliderPsi = Slider(axPsi, 'Psi', 0, 180, valinit=self.psi, valfmt='%1d')
self.sliderPsi.on_changed(self.onUpdate)
# Button - Previous
axPrev = plt.axes([0.18, 0.03, 0.1, 0.05])
self.buttonPrev = Button(axPrev, 'Previous')
self.buttonPrev.on_clicked(self.onPrevious)
# Button - Next
axNext = plt.axes([0.29, 0.03, 0.1, 0.05])
self.buttonNext = Button(axNext, 'Next')
self.buttonNext.on_clicked(self.onNext)
# Button - Reset
axReset = plt.axes([0.73, 0.03, 0.1, 0.05])
self.buttonReset = Button(axReset, 'Reset')
self.buttonReset.on_clicked(self.onReset)
self.onDraw()
开发者ID:amergl,项目名称:Numerik2,代码行数:35,代码来源:Vorwaertsproblem.py
示例13: __init__
def __init__(self, viewer, Npoints, data):
self.viewer = viewer
self.Npoints = Npoints
self.data = data
self.pointsh = []
plt.sca(self.viewer.ax)
axclick = plt.axes([0.09, 0.15, 0.1, 0.075])
self.bclick = Button(axclick, 'Click')
self.bclick.on_clicked(self.click)
axreset = plt.axes([0.20, 0.15, 0.1, 0.075])
self.breset = Button(axreset, 'Reset')
self.breset.on_clicked(self.reset)
axfileload = plt.axes([0.09, 0.05, 0.1, 0.075])
self.bfileload = Button(axfileload, 'Load...')
self.bfileload.on_clicked(self.fileLoad)
axfilesave = plt.axes([0.20, 0.05, 0.1, 0.075])
self.bfilesave = Button(axfilesave, 'Save...')
self.bfilesave.on_clicked(self.fileSave)
self.showPoints()
开发者ID:u0078867,项目名称:Py3DFreeHandUS,代码行数:26,代码来源:segment.py
示例14: setup_plot
def setup_plot():
global rate_slider, delta_slider, fig, ax, l, radio
fig, ax = plt.subplots()
ax.grid('on')
plt.subplots_adjust(left=0.25, bottom=0.25)
moneyFmt = FuncFormatter(money)
ax.yaxis.set_major_formatter(moneyFmt)
s = calc_compounding( rate, periods, principal, contribution, delta,inflation)
t = np.arange(2014, (2014+periods))
l, = plt.plot(t,s, lw=2, color='red')
plt.ylabel("Investment Loss (FV)")
plt.axis([2014, (2014+periods), 0, principal])
plt.axis('tight')
axfreq = plt.axes([0.25, 0.1, 0.65, 0.03], axisbg=axcolor)
axamp = plt.axes([0.25, 0.15, 0.65, 0.03], axisbg=axcolor)
rate_slider = Slider(axfreq, 'Avg.Returns', 4, 8, valinit=rate)
delta_slider = Slider(axamp, 'Delta', 0.1, 1, valinit=delta)
resetax = plt.axes([0.8, 0.025, 0.1, 0.04])
button = Button(resetax, 'Reset', color=axcolor, hovercolor='0.975')
rate_slider.on_changed(update)
delta_slider.on_changed(update)
button.on_clicked(reset)
rax = plt.axes([0.015, 0.15, 0.15, 0.15], axisbg=axcolor)
radio = RadioButtons(rax, ('0','3000', '6000', '9000'), active=0)
radio.on_clicked(contribution_update)
plt.show()
return rate_slider,delta_slider,fig,ax,l,radio
开发者ID:bansalr,项目名称:fund_allocation,代码行数:30,代码来源:rate_of_return.py
示例15: __setup_plots
def __setup_plots(self):
# Some actual plots.
self.plot_axis_z = plt.subplot2grid((6, 20), (0, 0), colspan=18)
self.plot_axis_n = plt.subplot2grid((6, 20), (1, 0), colspan=18)
self.plot_axis_e = plt.subplot2grid((6, 20), (2, 0), colspan=18)
self.misfit_axis = plt.subplot2grid((6, 20), (3, 0), colspan=11,
rowspan=3)
self.colorbar_axis = plt.subplot2grid((6, 20), (3, 12), colspan=1,
rowspan=3)
#self.adjoint_source_axis = plt.subplot2grid((6, 8), (4, 0), colspan=4,
#rowspan=1)
self.map_axis = plt.subplot2grid((6, 20), (3, 13), colspan=8,
rowspan=3)
# Plot the map and the beachball.
bounds = self.project.domain["bounds"]
self.map_obj = visualization.plot_domain(bounds["minimum_latitude"],
bounds["maximum_latitude"], bounds["minimum_longitude"],
bounds["maximum_longitude"], bounds["boundary_width_in_degree"],
rotation_axis=self.project.domain["rotation_axis"],
rotation_angle_in_degree=self.project.domain["rotation_angle"],
plot_simulation_domain=False, show_plot=False, zoom=True)
visualization.plot_events([self.event], map_object=self.map_obj)
# All kinds of buttons [left, bottom, width, height]
self.axnext = plt.axes([0.90, 0.95, 0.08, 0.03])
self.axprev = plt.axes([0.90, 0.90, 0.08, 0.03])
self.axreset = plt.axes([0.90, 0.85, 0.08, 0.03])
self.bnext = Button(self.axnext, 'Next')
self.bprev = Button(self.axprev, 'Prev')
self.breset = Button(self.axreset, 'Reset Station')
开发者ID:msimon00,项目名称:LASIF,代码行数:32,代码来源:misfit_gui.py
示例16: show
def show(self):
plot_idx = 0
self.current_plot_idx = plot_idx
self.plots[plot_idx].set_visible(True)
self.set_data_cursor()
if(len(self.plots) > 1 and self.use_matplotlib_widget is True):
button_width = .05
index_width = .03*len(str(len(self.plots)-1))
button_height = .05
button_bottom = .025
center = .5
margin = .005
axes_prev_rect = [center - index_width/2 - margin - button_width,
button_bottom, button_width, button_height]
axes_prev = self.figure.add_axes(axes_prev_rect)
self.button_prev = Button(axes_prev, '<')
self.button_prev.on_clicked(self.show_prev_plot)
self.index_text = self.figure.text(
center - index_width/2, (button_bottom+button_height)/2,
"{}/{}".format(self.current_plot_idx, len(self.plots)-1)
)
axes_next_rect = [center + index_width/2 + margin,
button_bottom, button_width, button_height]
axes_next = self.figure.add_axes(axes_next_rect)
self.button_next = Button(axes_next, '>')
self.button_next.on_clicked(self.show_next_plot)
self.figure.show()
开发者ID:chan-y-park,项目名称:mose,代码行数:32,代码来源:plotting.py
示例17: param_gui
def param_gui(letter_name, shapeModeler):
global sliders, mainPlot, fig, pca_params
fig, ax = plt.subplots()
whiteSpace = 0.15 + num_params*0.05
plt.subplots_adjust( bottom=whiteSpace)
plt.axis('equal')
#plot of initial shape
params = np.zeros((num_params,1))
shape = shapeModeler.makeShape(params)
shape = ShapeModeler.normaliseShape(shape)
numPointsInShape = len(shape)/2
x_shape = shape[0:numPointsInShape]
y_shape = shape[numPointsInShape:]
mainPlot, = plt.plot(x_shape, -y_shape)
plt.axis([-1, 1, -1, 1],autoscale_on=False, aspect='equal')
plt.title(letter_name)
#add sliders to modify parameter values
parameterVariances = shapeModeler.getParameterVariances()
sliders = [0]*num_params
for i in range(num_params):
slider = Slider(plt.axes([0.25, 0.1+0.05*(num_params-i-1), 0.65, 0.03], axisbg=axcolor),
'Parameter '+str(i+1), -5*parameterVariances[i], 5*parameterVariances[i], valinit=0)
slider.on_changed(partial(update, shapeModeler))
sliders[i] = slider
resetax = plt.axes([0.8, 0.025, 0.1, 0.04])
button = Button(resetax, 'Reset', color=axcolor, hovercolor='0.975')
button.on_clicked(reset)
plt.show()
return pca_params
开发者ID:chili-epfl,项目名称:shape_learning,代码行数:34,代码来源:generate_custom_parametrization.py
示例18: slider
class slider():
def __init__(self,res):
self.res=res
def slider_bar(self,res):
#setupthe slider
axcolor = 'lightgoldenrodyellow'
self.axtime = plt.axes([0.1, 0.05, 0.8, 0.03], axisbg=axcolor)
self.stime = Slider(self.axtime, 'Timestep', 0, len(res.resobj.fils.fid.dimensions['Time']), valinit=0)
def update(val,res):
t = self.stime.val
res.refresh_plot(t)
self.stime.on_changed(update(self,res))
def foward_button(self,res):
self.fwdax = plt.axes([0.1, 0.1, 0.1, 0.04])
self.fwdb = Button(self.fwdax, 'forward', color='lightgoldenrodyellow', hovercolor='0.975')
self.fwdb.on_clicked(slider.update(res.resobj.timestep-1,res))
开发者ID:chrisvos,项目名称:FVTools,代码行数:27,代码来源:plot_types.py
示例19: __init__
def __init__(self, image, low, high):
self.image_name = image
self.low = low
self.high = high
self.filter = None
self.output = None
self.filter_type = None
self.padRows = None
self.padCols = None
original_input = cv2.imread(image,0)
rows, cols = original_input.shape
if(rows < cols):
original_input = cv2.transpose(original_input)
self.transposed = True
else:
self.transposed = False
rows, cols = original_input.shape
optimalRows = cv2.getOptimalDFTSize(rows)
optimalCols = cv2.getOptimalDFTSize(cols)
self.padRows = optimalRows - rows
self.padCols = optimalCols - cols
self.input = np.zeros((optimalRows,optimalCols))
self.input[:rows,:cols] = original_input
self.dftshift = get_dft_shift(self.input)
plt.subplots_adjust(left=0, bottom=0.05, right=1, top=1, wspace=0, hspace=0)
plt.subplot(131)
plt.axis('off')
plt.title('original image')
plt.imshow(self.input, cmap = 'gray',interpolation='nearest')
self.axslow = plt.axes([0.05, 0.01, 0.5, 0.02])
self.slow = Slider(self.axslow, 'low', 0.01, 1, valinit=self.low)
self.slow.on_changed(self.updateLow)
self.axhigh = plt.axes([0.05, 0.03, 0.5, 0.02])
self.shigh = Slider(self.axhigh, 'high', 0.01, 1, valinit=self.high)
self.shigh.on_changed(self.updateHigh)
self.slow.slidermax=self.shigh
self.shigh.slidermin=self.slow
self.axfilter = plt.axes([0.62, 0.01, 0.15, 0.04])
self.rfilter = RadioButtons(self.axfilter, ('Gaussian Filter', 'Ideal Filter'))
self.rfilter.on_clicked(self.updateFilterType)
self.filter_type = self.rfilter.value_selected
self.axprocess = plt.axes([0.8, 0.01, 0.08, 0.04])
self.bprocess = Button(self.axprocess, 'Process')
self.bprocess.on_clicked(self.process)
self.axsave = plt.axes([0.88, 0.01, 0.08, 0.04])
self.bsave = Button(self.axsave, 'Save')
self.bsave.on_clicked(self.save)
开发者ID:huyuji,项目名称:garden,代码行数:60,代码来源:filter.py
示例20: __init__
def __init__(self, image_sequence):
# Fix the size of subplot
self.fig, self.axes = plt.subplots(2, sharey=True, figsize=(10, 5))
# Set background to be gray
self.fig.patch.set_facecolor('#333333')
# Store image sequence in self.seq and display the sequence
self.seq = image_sequence
self.image = self.seq.init_image()
self.image2 = self.seq.init_image_original()
self.image_figure = plt.subplot2grid((3, 3), (0, 0), colspan=3, rowspan=2)
self.image_figure.axis('off')
self.image_plot = self.image_figure.imshow(self.image)
self.image_figure.set_title('Dinic', color='white')
self.init_figure = plt.subplot2grid((3, 3), (2, 1))
self.init_figure.axis('off')
self.init_plot = plt.imshow(self.image2)
self.init_figure.set_title('Flow Graph', color = 'white' )
self.text_figure = plt.subplot2grid((3, 3), (2, 2))
self.text_figure.axis('off')
self.text_figure.set_title('',color = 'white')
plt.subplots_adjust(bottom=0.2)
axnext = plt.axes([0.81, 0.05, 0.1, 0.075])
bnext = Button(axnext, 'Next')
bnext.on_clicked(self.next)
plt.show()
开发者ID:vignesh-m,项目名称:dinic-visualization,代码行数:33,代码来源:image_display.py
注:本文中的matplotlib.widgets.Button类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论