本文整理汇总了Python中matplotlib.widgets.Slider类的典型用法代码示例。如果您正苦于以下问题:Python Slider类的具体用法?Python Slider怎么用?Python Slider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Slider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: showimages
def showimages(img1, img2, pathtosave):
def press(event):
sys.stdout.flush()
if event.key == 'escape':
sys.exit(0)
elif event.key == ' ':
plt.savefig(os.path.join(pathtosave, 'overlay.pdf'), bbox_inches='tight')
print 'saved'
fig, ax = plt.subplots()
fig.canvas.mpl_connect('key_press_event', press)
plt.subplots_adjust(0.15, 0.1, 0.9, 0.98)
im = ax.imshow(img1)
axcolor = 'lightgoldenrodyellow'
BAR_HEIGHT = 0.03
axalpha = plt.axes([0.2, 0.2 * BAR_HEIGHT, 0.7, BAR_HEIGHT], axisbg = axcolor)
# axmax = plt.axes([0.2, BAR_HEIGHT + 0.4 * BAR_HEIGHT, 0.7, BAR_HEIGHT], axisbg = axcolor)
salpha = Slider(axalpha, 'Alpha', 0.0, 1.0, valinit = 1.0)
def update(event):
curralpha = salpha.val
ax.hold(False)
ax.imshow(img1, alpha = curralpha)
ax.hold(True)
ax.imshow(img2, alpha = 1 - curralpha)
plt.draw()
return curralpha
salpha.on_changed(update)
plt.show()
开发者ID:giuliomarin,项目名称:cvip-python,代码行数:33,代码来源:overlayimages.py
示例2: 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
示例3: plotter
def plotter():
'''
This process is supposed to handle the graphs.
Not pretty at the moment... but then matplotlib never is.
'''
signal.signal(signal.SIGINT, signal.SIG_IGN) # Ignore keyboard interrupt signal, parent process will handle.
waterfall_size = 150 # This makes it about 75 seconds in theory. Drawing the graph sometimes takes a bit longer.
fig = plt.figure(figsize=(20,15))
plt.subplots_adjust(left = 0.1, bottom = 0.25)
ax = plt.subplot(1, 1, 1)
line_lcp, = ax.plot([], [], 'bo', lw=1)
line_rcp, = ax.plot([], [], 'ro', lw=1)
ax.set_xlim(0,400)
vav_data_lcp = collections.deque(maxlen = waterfall_size)
vav_data_rcp = collections.deque(maxlen = waterfall_size)
slider_ax = plt.axes([0.25, 0.1, 0.65, 0.03])
video_average_length_slider = Slider(slider_ax, 'VAv', 1, waterfall_size, valinit=video_average_length.value)
def update(val):
video_average_length.value = int(video_average_length_slider.val)
fig.canvas.draw_idle()
video_average_length_slider.on_changed(update)
def init():
x = np.zeros(data_width)
y = np.zeros(data_width)
line_lcp.set_data(x,y)
line_rcp.set_data(x,y)
return line,
def animate(*args):
if script_run.value != 1:
sys.exit()
x = np.arange(0, 400, 400.0 / 1024.0)
vav_data_lcp.appendleft(data_stream_1[:])
vav_data_rcp.appendleft(data_stream_2[:])
lcp = np.zeros(data_width)
rcp = np.zeros(data_width)
for i in range(video_average_length.value):
if i < len(vav_data):
lcp += np.array(vav_data_lcp[i])
rcp += np.array(vav_data_rcp[i])
lcp /= video_average_length.value
rcp /= video_average_length.value
graph_max = 0
if lcp.max() > rcp.max():
graph_max = lcp.max()
else:
graph_max = rcp.max()
ax.set_ylim(0,graph_max + 1)
line_lcp.set_data(x,lcp)
line_rcp.set_data(x.rcp)
return line,
# Set the animation off to a start...
anim = animation.FuncAnimation(fig, animate, init_func=init, blit=True, interval=500)
plt.show()
print 'plotter process finished.'
开发者ID:james-smith-za,项目名称:python-sandbox,代码行数:60,代码来源:spectro.py
示例4: 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
示例5: from_partial
def from_partial(plot_func,**kwargs):
num_params = len(kwargs)
fig = plt.figure()
main_ax = fig.add_subplot(111)
fig.subplots_adjust(bottom=bottom_pad + (num_params+1)*per_slider)
param_vals = dict((param_name,(lo+hi)/2) for param_name, (lo,hi) in kwargs.items())
plot_func = partial(plot_func,main_ax)
plot_func(param_vals)
def update(*args):
for param_name, slider in zip(param_vals,sliders):
param_vals[param_name] = slider.val
main_ax.cla()
plot_func(param_vals)
# using autoscale_view makes the axes shrink *and* grow
main_ax.relim()
main_ax.autoscale_view()
fig.canvas.draw()
sliders = []
for idx, (param_name, (lo,hi)) in enumerate(kwargs.items()):
ax = fig.add_axes([0.25,bottom_pad+per_slider*idx,0.65,3/5*per_slider],axisbg=bgcolor)
slider = Slider(ax, param_name, lo, hi, valinit=param_vals[param_name])
slider.on_changed(update)
sliders.append(slider)
plt.axes(main_ax)
开发者ID:mattjj,项目名称:py-manipulate,代码行数:31,代码来源:manipulate.py
示例6: plotInteractive
def plotInteractive( data ):
ax = plt.subplot(111)
plt.subplots_adjust(bottom=0.25)
t = sorted(data.keys())
pl = plt.scatter([0],[0],s=10,linewidths=(0,0,0))
plt.axis([0, 2, 0, 2])
axTime = plt.axes([0.25, 0.1, 0.65, 0.03])
sTime = Slider(axTime, 'Time', min(t), max(t), valinit=min(t))
def updateTime(val):
t0 = sTime.val
dt = abs(np.array(t)-t0)
t_in = t[dt.argmin()]
px = getpx(data,t_in)
pv = getpv(data,t_in)
pl.set_offsets(px)
pl.set_array(pv)
plt.draw()
updateTime(min(t))
sTime.on_changed(updateTime)
plt.show(block=False)
开发者ID:bbanerjee,项目名称:ParSim,代码行数:25,代码来源:plotTest.py
示例7: iplot_spectrum_ds
def iplot_spectrum_ds(ds, init = True,
sigmarng = [0.05, 1.5], taurng = [0,4], **kwargs):
"""
Plots spectrum from TlacDatSet interactively using matplotlib.
NOT FINISHED >> see tlac_web instead
Keyword Arguments:
ds -- TlacDatSet instance to plot
init --- If true (default) plot will be initialized first
sigmarng -- Range for intrinsic spectrum width. Measured in
units of the actual sigma_i (default [0,1.5])
taurng -- Range for dust optical depth tau_d (default [0, 4])
**kwargs -- Will be passes to `tlac_analysis.plot_spectrum`
"""
if(not isinstance(ds, TlacDatSet)):
raise ValueError("ds has to be a TlacDatSet instance")
dat = ds['Lya','x']
sigmar = ds.header['emission', 'frequency_param' ]
if(init):
plot_init()
plt.gcf().subplots_adjust(top = 0.95, bottom = 0.05)
plot_spectrum(dat, np.ones(len(dat)), **kwargs)
fig = plt.gcf()
ax = fig.axes[0]
line = ax.lines[-1]
nbins = len(line.get_xdata())
bm = fig.subplotpars.bottom
fig.subplots_adjust(bottom = bm + 0.04)
axsigma = plt.axes([0.2, bm - 0.03, 0.65, 0.03])
ssigma = Slider(axsigma, r"$\sigma_i$", sigmarng[0] * sigmar,
sigmarng[1] * sigmar, valinit=sigmar)
def update(val):
sigma = ssigma.val
w = tlac_weights(ds, sigma, 0)
x,y = plot_spectrum(dat, w, plot = False, **kwargs)
line.set_xdata(x)
line.set_ydata(y)
ymax = ax.get_ylim()[1]
if(np.max(y) > 1.1 * ymax):
ax.set_ylim(ymax = 1.5 * ymax)
elif(np.max(y) < 0.5 * ymax):
ax.set_ylim(ymax = 0.5 * ymax)
fig.canvas.draw_idle()
ssigma.on_changed(update)
# change current axis back
plt.sca(ax)
plt.show()
# have to return ref to slider. otherwise unresponsive!
return fig, ax, ssigma
开发者ID:laurennc,项目名称:CGMemission,代码行数:60,代码来源:tlac_plot.py
示例8: cube_show_slider
def cube_show_slider(cube, axis=2, **kwargs):
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button, RadioButtons
# check dim
if not cube.ndim == 3:
raise ValueError("cube should be an ndarray with ndim == 3")
# generate figure
fig = plt.figure()
ax = plt.subplot(111)
fig.subplots_adjust(left=0.25, bottom=0.25)
# select first image
s = [slice(0, 1) if i == axis else slice(None) for i in xrange(3)]
im = cube[s].squeeze()
# display image
l = ax.imshow(im, **kwargs)
axcolor = 'lightgoldenrodyellow'
ax = fig.add_axes([0.25, 0.1, 0.65, 0.03], axisbg=axcolor)
slider = Slider(ax, 'Axis %i index' % axis, 0, cube.shape[axis] - 1,
valinit=0, valfmt='%i')
def update(val):
ind = int(slider.val)
s = [slice(ind, ind + 1) if i == axis else slice(None) for i in xrange(3)]
im = cube[s].squeeze()
l.set_data(im, **kwargs)
fig.canvas.draw()
slider.on_changed(update)
plt.show()
开发者ID:PieterBauweraerts,项目名称:py4sp,代码行数:33,代码来源:plot_sp.py
示例9: run
def run(self):
for varname,range in self.ranges.iteritems():
if range is None:
raise ValueError("no range specified for slider %s." % varname)
def update(val):
d = dict([(k, self.sliders[k].val) for k in self.sliders.keys()])
# pull members into current scope -> no self. in cutstring
vars = self.vars
weights = self.weights
basemask = self.basemask
# evaluate cutstring and combine with basemask
mask = basemask & eval(self.cutstring % d)
self.updatefunc(self, vars, weights, mask)
self.sliderfig = p.figure(figsize=(3,len(self.ranges)*.4))
self.sliders = dict()
space = .05
height = (1. - (len(self.ranges)+2)*space) / float(len(self.ranges))
for i,(varname,range) in enumerate(self.ranges.iteritems()):
ax = p.axes([0.25, 1-float(i+1)*(space+height), 0.5, height])
slider = Slider(ax, varname, range[0],range[1], valinit=(range[1]-range[0])/2.)
slider.on_changed(update)
self.sliders[varname] = slider
self.initfunc(self,self.vars,self.weights,self.basemask)
开发者ID:IceCube-SPNO,项目名称:dashi,代码行数:28,代码来源:visualcutter.py
示例10: create_sliders
def create_sliders(self):
for i, name in enumerate(self.names):
dim = self.def_dim + i * self.del_dim
axes = self.f.add_axes(dim, axisbg = self.axcolor)
slider = Slider(axes, name, 0, 10, valinit=1)
slider.on_changed(self.update)
self.cont_of_slid[name] = (axes, slider)
开发者ID:Iceman9,项目名称:MofDS-GUI,代码行数:7,代码来源:map_gui.py
示例11: 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
示例12: init
def init():
""" Set up the initial conditions """
# Sets up initial dimensions
M.figure(figsize=(8,8))
density=N.loadtxt(os.path.join(sys.path[0], './densmesh.txt'))
# Real Fourier transform of "density"
density_k = N.fft.rfftn(density*1e3) # 1e3 to enhance contrast
global psi
psi = zeldovich(density_k)
# Zel'dovich displacement field
global scale
global slider_scale
scale = 1.0
slider_scale = 50.0
axcolor = 'lightgoldenrodyellow'
axScale = plt.axes([0.15, 0.1, 0.7, 0.03], axisbg=axcolor)
slider_scale = Slider(axScale, 'Scale', 0.0, 50.0, 1.0)
slider_scale.on_changed(update)
# Attempting to removed axes from the graph
plt.axes([0.15, 0.15, 0.7, 0.7])
plt.xticks([])
plt.yticks([])
return density_k, psi
开发者ID:ark2003,项目名称:FoldYourOwnUniverse,代码行数:30,代码来源:foldyourown.py
示例13: Explorer
class Explorer(object):
"""A simple interactive slicer that "pans" a series of 2D slices along a
given axis of a 3D volume. Additional kwargs are passed to "imshow"."""
def __init__(self, data, axis=2, **kwargs):
self.data = data
self.axis = axis
self.start, self.stop = 0, data.shape[self.axis] - 1
kwargs['cmap'] = kwargs.get('cmap', 'gray_r')
self.fig, self.ax = plt.subplots()
self.im = self.ax.imshow(self[self.start], **kwargs)
self.ax.axis('off')
self.sliderax = self.fig.add_axes([0.2, 0.02, 0.6, 0.03])
self.slider = Slider(self.sliderax, 'Z-slice', self.start, self.stop,
valinit=self.start, valfmt='%i')
self.slider.on_changed(self.update)
def __getitem__(self, i):
slices = self.data.ndim * [slice(None)]
slices[self.axis] = i
return self.data[slices].swapaxes(0, 1)
def update(self, val):
dat = self[int(val)]
self.im.set(data=dat, clim=[dat.min(), dat.max()])
self.fig.canvas.draw()
def show(self):
plt.show()
开发者ID:hnetss,项目名称:scipy2014-3d_seismic,代码行数:31,代码来源:utilities.py
示例14: interpolation
def interpolation(threshold, X_Smooth1, Smooth_Y_Coordinates):
Smooth_X_npy = np.asarray(X_Coordinates)
Smooth_Y_npy = np.asarray(Smooth_Y_Coordinates)
f = interp1d(Smooth_X_npy, Smooth_Y_npy, kind = "cubic" )
temp = f(X_Coordinates)
plt.close('all')
fig, ax = plt.subplots(5)
fig.suptitle("Neutron Imaging Curve Smoothing", fontsize="x-large")
ax[0] = plt.subplot2grid((6,7), (0,0), rowspan=2, colspan=3)
ax[0].plot(X_Coordinates, Y_Coordinates)
ax[0].set_title('Original Plot')
ax[1] = plt.subplot2grid((6,7), (3,0), rowspan=2, colspan=3)
ax[1].plot(X_Coordinates, beta_list, 'r.-')
ax[1].axhline(y=threshold, linewidth=1, color='k')
ax[1].set_title('Peak Plot', )
ax[2] = plt.subplot2grid((6,7), (0,4), rowspan=2, colspan=3)
ax[2].plot(X_Coordinates, Smooth_Y_Coordinates)
ax[2].set_title('Smoothed graph')
ax[3] = plt.subplot2grid((6,7), (3,4), rowspan=2, colspan=3)
ax[3].plot(X_Coordinates, f(X_Coordinates))
ax[3].set_title('Interpolated')
ax[4] = plt.subplot2grid((6,7), (5,0), colspan=7)
ax[4].set_position([0.25, 0.1, 0.65, 0.03])
thres = Slider(ax[4], 'Threshold', 0.000, 0.005, valinit = threshold, valfmt='%1.5f')
workbook = xlwt.Workbook(encoding='ascii')
sheet = workbook.add_sheet("Sheet")
sheet.write(0, 0, "(Raw-OB)/OB")
sheet.write(0, 1, "wavelength (angs)")
for i in range(len(X_Coordinates)):
sheet.write(i+1, 0, X_Coordinates[i])
sheet.write(i+1, 1, temp[i])
workbook.save(outputfile)
def update(val):
threshold = thres.val
print ("Threshold value: "), threshold
smoothing_Plot(total_Span, threshold)
fig.canvas.draw_idle()
thres.on_changed(update)
plt.show()
fig2, ax2 = plt.subplots(2)
ax2[0] = plt.subplot2grid((7,2), (0,0), rowspan=3, colspan=2)
ax2[0].plot(X_Coordinates, Y_Coordinates)
ax2[0].set_title('Original Plot')
for i in X_Smooth1:
plt.axvline(x = i, linewidth=1, color='k')
ax2[1] = plt.subplot2grid((7,2), (4,0), rowspan=3, colspan=2)
ax2[1].plot(X_Coordinates, f(X_Coordinates))
ax2[1].set_title('Interpolated')
for i in X_Smooth1:
plt.axvline(x = i, linewidth=1, color='k')
plt.show()
开发者ID:phaniparsa,项目名称:NeutronImagingProject_ORNL_UNLV,代码行数:60,代码来源:Algo1.py
示例15: _create_controls
def _create_controls(self):
self._freq_ax = plt.axes([0.2, 0.19, 0.2, 0.03])
self._freq_slider = Slider(self._freq_ax,
'Frequency',
0,
self.samplerate / 2.0,
valinit = self.frequency)
self._freq_slider.on_changed(self.set_signal_frequency)
self._ampl_ax = plt.axes([0.2, 0.1, 0.2, 0.03])
self._ampl_slider = Slider(self._ampl_ax,
'Amplitude',
-100,
0,
valinit = dcv.lin2db(self.amplitude))
self._ampl_slider.on_changed(self.set_signal_amplitude)
self._signaltype_ax = plt.axes([0.5, 0.05, 0.15, 0.20])
self._signaltype_radio = RadioButtons(self._signaltype_ax,
('Sine', 'Square', 'Sawtooth',
'Triangle', 'Noise', 'Constant'))
self._signaltype_radio.on_clicked(self.set_signal_type)
self._windowtype_ax = plt.axes([0.7, 0.05, 0.15, 0.20])
self._windowtype_radio = RadioButtons(self._windowtype_ax,
('Flat', 'Hanning', 'Hamming', 'Blackman'))
self._windowtype_radio.on_clicked(self.set_window_type)
开发者ID:PengYingChuan,项目名称:yodel,代码行数:27,代码来源:fourier_analysis.py
示例16: cal_threshold
def cal_threshold(image, tr):
'''
shows the before and after for thresholding, where the threshold can be set
by a slider
'''
assert image.ndim ==2, 'This is not a single-channel image! Use single-channel images'
im = image.astype('uint8')
#create the axes for the slider
axcolor = 'teal'
ax1 = plt.axes([.15,.2,.65,.03],axisbg=axcolor)
#create the slider
s1 = Slider(ax1, 'Threshold', 0, 255, valinit=tr)
#actual thresholding: compare each pixel in the image to the threshold
trim = im > tr
plt.subplot(221),plt.imshow(im),plt.title('Original')
plt.subplot(222),plt.imshow(trim),plt.title('After thresholding')
def update(val):
vtr = s1.val
trim = im > vtr
plt.subplot(222),plt.imshow(trim),plt.title('After thresholding')
s1.on_changed(update)
plt.show()
#trim is a binary image - convert it to full colorscale by multiplying with
#255
return trim*255, s1.val
开发者ID:AFvanloo,项目名称:flyeye,代码行数:32,代码来源:flyeye.py
示例17: __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
示例18: __init__
def __init__(self, image, dragging=True, **kwargs):
# init PointBrowser
super(FindCenters,self).__init__(image,[[None,None]],**kwargs);
self.axis.set_title('FitHexagonCenters: %s' % self.imginfo['desc']);
self.fig.subplots_adjust(bottom=0.2); # space for sliders
# add slider for neighborhood size
self.nbhd_size = 5; # neighborhood size
axNbhd = self.fig.add_axes([0.2, 0.05, 0.1, 0.04]);
self.sNbhd = Slider(axNbhd,'neighbors ',2,20,valinit=self.nbhd_size,\
valfmt=' (%d)',dragging=dragging);
self.sNbhd.on_changed(self.ChangeNeighborhood);
# add slider for number of points
self.num_points = 1e6; # number of local maxima to find
axNum = self.fig.add_axes([0.45, 0.05, 0.3, 0.04]);
self.sNum = Slider(axNum, 'points ',0,100,valinit=self.num_points,\
valfmt=' (%d)',dragging=dragging);
self.sNum.on_changed(self.ChangeMaxPoints);
# add buttons
axRefine = self.fig.add_axes([0.85, 0.7, 0.1, 0.04]);
self.bRefine = Button(axRefine,'Refine');
self.bRefine.on_clicked(self.RefineCenters);
# initial calculation of local maximas
self.ChangeNeighborhood(self.nbhd_size);
开发者ID:rhambach,项目名称:TEMimage,代码行数:28,代码来源:find_peaks.py
示例19: 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
示例20: plot_fits
def plot_fits(self, X, X_pred, plot_preds = True):
self.plot_preds = plot_preds
import matplotlib
self.colors = ['r', 'g', 'b']
more_colors = matplotlib.colors.cnames.keys()
shuffle(more_colors)
# print self.colors
# print more_colors
self.colors.extend(more_colors)
self.trial_groups = self.split_trial_groups()
self.X = X
self.X_pred = X_pred
# set-up the plot window
self.fig, self.ax = plt.subplots(figsize=(12,8))
plt.subplots_adjust(bottom=0.25)
# make sliders
axcolor = 'lightgoldenrodyellow'
self.axtrial = plt.axes([0.25, 0.05, 0.65, 0.03], axisbg=axcolor)
self.axspot = plt.axes([0.25, 0.1, 0.65, 0.03], axisbg=axcolor)
self.axclass = plt.axes([0.25, 0.15, 0.65, 0.03], axisbg=axcolor)
# need to update to find the number of classes, trial_groups
self.strial = Slider(self.axtrial, 'Trial', 0, self.n_trial_groups, valinit=0)
self.sspot = Slider(self.axspot, 'Spot', 1, len(self.column_headers), valinit=1)
self.sclass = Slider(self.axclass, 'Class', 0, len(self.groups), valinit=0)
self.strial.on_changed(self.update_fits)
self.sspot.on_changed(self.update_fits)
self.sclass.on_changed(self.update_fits)
self.plot_fit(spot=1, group=0, trial=0, averages=self.averages)
plt.show()
开发者ID:fcesco,项目名称:smelling_sepsis,代码行数:35,代码来源:timeseriesplotter.py
注:本文中的matplotlib.widgets.Slider类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论