本文整理汇总了Python中visvis.clf函数的典型用法代码示例。如果您正苦于以下问题:Python clf函数的具体用法?Python clf怎么用?Python clf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PlotReferencePhase
def PlotReferencePhase (self, event) :
"""
Plot reference phase
"""
visvis.cla(); visvis.clf();
# get actual amplitude and phased
phase = self.GetReferencePhase()[0]
ampl = np.ones(phase.size)
ampl, phase = self.DevPulseShaper.GetUnwrappedAmplPhase(ampl, phase)
# Wrap the phase in radians
phase %= (2*np.pi)
# Get the phase in unites of 2*pi
phase /= (2*np.pi)
visvis.subplot(211)
visvis.plot(phase)
visvis.ylabel ('Reference phase')
visvis.xlabel ('puls shaper pixel number')
visvis.title ('Current reference phase (in unites of 2*pi)')
visvis.subplot(212)
visvis.plot( self.corrections, lc='r',ms='*', mc='r' )
visvis.ylabel ('Value of coefficients')
visvis.xlabel ('coefficient number')
visvis.title ('Value of corrections')
示例2: _createWindow
def _createWindow(self, name, im, axis):
vv.figure()
vv.gca()
vv.clf()
fig = vv.imshow(im)
dims = im.shape
''' Change color bounds '''
if im.dtype == np.uint8:
fig.clim.Set(0, 255)
else:
fig.clim.Set(0., 1.)
fig.GetFigure().title = name
''' Show ticks on axes? '''
if not axis:
fig.GetAxes().axis.visible = False
bgcolor = (0.,0.,0.)
else:
fig.GetAxes().axis.showBox = False
bgcolor = (1.,1.,1.)
''' Set background color '''
fig.GetFigure().bgcolor = bgcolor
fig.GetAxes().bgcolor = bgcolor
''' Setup keyboard event handler '''
fig.eventKeyDown.Bind(self._keyHandler)
win = {'name':name, 'canvas':fig, 'shape':dims, 'keyEvent':None, 'text':[]}
self.open_windows.append(win)
return win
示例3: DisplayOptimization
def DisplayOptimization (self) :
"""
Display the progress of optimization
"""
wx.Yield()
# abort, if requested
if self.need_abort : return
def GetValueColourIter (d) :
return izip_longest( d.itervalues(), ['r', 'g', 'b', 'k'], fillvalue='y' )
visvis.cla(); visvis.clf()
visvis.subplot(211)
# Plot optimization statistics
for values, colour in GetValueColourIter(self.optimization_log) :
try : visvis.plot ( values, lc=colour )
except Exception : pass
visvis.xlabel ('iteration')
visvis.ylabel ('Objective function')
visvis.legend( self.optimization_log.keys() )
# Display reference signal
visvis.subplot(212)
# Plot reference signal
for values, colour in GetValueColourIter(self.log_reference_signal) :
try : visvis.plot ( values, lc=colour )
except Exception : pass
visvis.xlabel ('iteration')
visvis.ylabel ("Signal from reference pulse")
visvis.legend( ["channel %d" % x for x in self.log_reference_signal.keys()] )
示例4: ShowImg
def ShowImg (self) :
"""
Draw image
"""
if self._abort_img :
# Exit
return
# Get image
img = self.dev.StopImgAqusition()
# Display image
try :
if img <> RETURN_FAIL :
self._img_plot.SetData(img)
except AttributeError :
visvis.cla()
visvis.clf()
self._img_plot = visvis.imshow(img)
visvis.title ('Camera view')
ax = visvis.gca()
ax.axis.xTicks = []
ax.axis.yTicks = []
# Start acquisition of histogram
self.dev.StartImgAqusition()
wx.CallAfter(self.ShowImg)
示例5: show
def show(items, normals=None):
"""Function that shows a mesh object.
"""
for item in items:
vv.clf()
# convert to visvis.Mesh class
new_normals = []
new_vertices = []
for k, v in item.vertices.iteritems():
new_normals.append(item.normal(k))
new_vertices.append(v)
mesh = item.to_visvis_mesh()
mesh.SetVertices(new_vertices)
mesh.SetNormals(new_normals)
mesh.faceColor = 'y'
mesh.edgeShading = 'plain'
mesh.edgeColor = (0, 0, 1)
axes = vv.gca()
if axes.daspectAuto is None:
axes.daspectAuto = False
axes.SetLimits()
if normals is not None:
for normal in normals:
sl = solidLine(normal, 0.15)
sl.faceColor = 'r'
# Show title and enter main loop
vv.title('Show')
app = vv.use()
app.Run()
示例6: StartInteractivelyMeasureSpectrum
def StartInteractivelyMeasureSpectrum (self, event) :
"""
This method display spectrum
"""
button = self.show_spectrum_button
if button.GetLabel() == button.__start_label__ :
self.StopAllJobs()
# get spectrometer's settings
spect_settings = self.SettingsNotebook.Spectrometer.GetSettings()
# Initiate spectrometer
if self.Spectrometer.SetSettings(spect_settings) == RETURN_FAIL : return
try : self.wavelengths = self.Spectrometer.GetWavelengths()
except AttributeError : self.wavelengths = None
# Clearing the figure
visvis.cla(); visvis.clf();
# Set up timer to draw spectrum
TIMER_ID = wx.NewId()
self.spectrum_timer = wx.Timer (self, TIMER_ID)
self.spectrum_timer.Start (spect_settings["exposure_time"])
wx.EVT_TIMER (self, TIMER_ID, self.DrawSpectrum)
# Chose plotting options
try :
self.is_autoscaled_spectrum = not(spect_settings["fix_vertical_axis"])
except KeyError :
self.is_autoscaled_spectrum = True
if not self.is_autoscaled_spectrum :
self.spectrum_plot_limits = ( spect_settings["vertical_axis_min_val"],
spect_settings["vertical_axis_max_val"] )
# Change button's label
button.SetLabel (button.__stop_label__)
elif button.GetLabel() == button.__stop_label__ :
# Stopping timer
self.spectrum_timer.Stop()
del self.spectrum_timer
# Delete the parameter for auto-scaling
del self.spectrum_plot_limits, self.is_autoscaled_spectrum
# Delate visvis objects
try : del self.__interact_2d_spectrum__
except AttributeError : pass
try : del self.__interact_1d_spectrum__
except AttributeError : pass
# Change button's label
button.SetLabel (button.__start_label__)
else : raise ValueError("Label is not recognized")
示例7: paint
def paint(self, visvis):
vv.clf()
colors = ["r", "g", "b", "c", "m", "y", "k"]
for index, dataset in enumerate(self._value):
l = visvis.plot(dataset, ms="o", mc=colors[index % len(colors)], mw="3", ls="", mew=0)
l.alpha = 0.3
self._a = vv.gca()
self._a.daspectAuto = True
示例8: _Plot
def _Plot(self, event):
# Make sure our figure is the active one
# If only one figure, this is not necessary.
#vv.figure(self.fig.nr)
# Clear it:
vv.clf()
# Plot:
pcv.drawDisplacements(self.a, self.coords, self.edof, self.dofsPerNode, self.elType, doDrawUndisplacedMesh=True, title="Example 09")
示例9: paint
def paint(self, visvis):
vv.clf()
colors = ['r','g','b','c','m','y','k']
for index, dataset in enumerate(self._value):
l = visvis.plot(dataset, ms='o', mc=colors[ index % len(colors) ], mw='3', ls='', mew=0 )
l.alpha = 0.3
self._a = vv.gca()
self._a.daspectAuto = True
示例10: MeasureSingleSpectrum
def MeasureSingleSpectrum (self, event=None) :
"""
Button <self.show_spectrum_button> was clicked
"""
button = self.show_spectrum_button
if button.GetLabel() == button.__start_label__ :
self.StopAllJobs()
# get spectrometer's settings
spect_settings = self.SettingsNotebook.Spectrometer.GetSettings()
# Initiate spectrometer
if self.Spectrometer.SetSettings(spect_settings) == RETURN_FAIL : return
self.wavelengths = self.Spectrometer.GetWavelengths()
# Clearing the figure
visvis.clf()
def draw_spectrum (event) :
"""Timer function """
spectrum = self.Spectrometer.AcquiredData()
if spectrum == RETURN_FAIL : return
# Display the spectrum
############### Take the log of spectrum ##########
#spectrum = spectrum / float(spectrum.max())
#np.log10(spectrum, out=spectrum)
##############################
ax = visvis.gca()
ax.Clear()
visvis.plot (self.wavelengths, spectrum)
visvis.xlabel("wavelength (nm)")
visvis.ylabel("counts")
# Display the current temperature
visvis.title ("Temperature %d (C)" % self.Spectrometer.GetTemperature() )
# Set up timer to draw spectrum
TIMER_ID = wx.NewId()
self.spectrum_timer = wx.Timer (self, TIMER_ID)
self.spectrum_timer.Start (spect_settings["exposure_time"])
# Change button's label
button.SetLabel (button.__stop_label__)
wx.EVT_TIMER (self, TIMER_ID, draw_spectrum)
elif button.GetLabel() == button.__stop_label__ :
# Stopping timer
self.spectrum_timer.Stop()
del self.spectrum_timer
# Change button's label
button.SetLabel (button.__start_label__)
else : raise ValueError("Label is not recognized")
示例11: main
def main(select=3, **kwargs):
"""Script main function.
select: int
1: Medical data
2: Blocky data, different every time
3: Two donuts
4: Ellipsoid
"""
import visvis as vv # noqa: delay import visvis and GUI libraries
# Create test volume
if select == 1:
vol = vv.volread('stent')
isovalue = kwargs.pop('level', 800)
elif select == 2:
vol = vv.aVolume(20, 128)
isovalue = kwargs.pop('level', 0.2)
elif select == 3:
with timer('computing donuts'):
vol = donuts()
isovalue = kwargs.pop('level', 0.0)
# Uncommenting the line below will yield different results for
# classic MC
# vol *= -1
elif select == 4:
vol = ellipsoid(4, 3, 2, levelset=True)
isovalue = kwargs.pop('level', 0.0)
else:
raise ValueError('invalid selection')
# Get surface meshes
with timer('finding surface lewiner'):
vertices1, faces1 = marching_cubes_lewiner(vol, isovalue, **kwargs)[:2]
with timer('finding surface classic'):
vertices2, faces2 = marching_cubes_classic(vol, isovalue, **kwargs)
# Show
vv.figure(1)
vv.clf()
a1 = vv.subplot(121)
vv.title('Lewiner')
m1 = vv.mesh(np.fliplr(vertices1), faces1)
a2 = vv.subplot(122)
vv.title('Classic')
m2 = vv.mesh(np.fliplr(vertices2), faces2)
a1.camera = a2.camera
# visvis uses right-hand rule, gradient_direction param uses left-hand rule
m1.cullFaces = m2.cullFaces = 'front' # None, front or back
vv.use().Run()
示例12: _Plot
def _Plot(self, event):
# Make sure our figure is the active one
# If only one figure, this is not necessary.
#vv.figure(self.fig.nr)
# Clear it
vv.clf()
# Plot
vv.plot([1,2,3,1,6])
vv.legend(['this is a line'])
示例13: __plot
def __plot(self, spectrum):
vv.clf()
axes = vv.gca()
axes.axis.showGrid = True
axes.axis.xLabel = 'Frequency (MHz)'
axes.axis.yLabel = 'Level (dB)'
total = len(spectrum)
count = 0.
for _time, sweep in spectrum.items():
alpha = (total - count) / total
vv.plot(sweep.keys(), sweep.values(), lw=1, alpha=alpha)
count += 1
示例14: AnalyzeTotalFluorescence
def AnalyzeTotalFluorescence (self, event=None) :
"""
`analyse_button` was clicked
"""
# Get current settings
settings = self.GetSettings()
# Apply peak finding filter
signal = self.peak_finders[ settings["peak_finder"] ](self.total_fluorescence)
# Scale to (0,1)
signal -= signal.min()
signal = signal / signal.max()
##########################################################################
# Partition signal into segments that are above the background noise
#signal = gaussian_filter(total_fluorescence, sigma=0.5)
background_cutoff = settings["background_cutoff"]
segments = [ [] ]
for num, is_segment in enumerate( signal > background_cutoff ) :
if is_segment :
# this index is in the segment
segments[-1].append( num )
elif len(segments[-1]) : # this condition is not to add empty segments
# Start new segments
segments.append( [] )
# Find peaks as weighted average of the segment
peaks = [ np.average(self.positions[S], weights=self.total_fluorescence[S]) for S in segments if len(S) ]
##########################################################################
# Saving the positions
self.chanel_positions_ctrl.SetValue( ", ".join( "%2.4f" % p for p in peaks ) )
##########################################################################
# Plot acquired data
visvis.cla(); visvis.clf()
visvis.plot( self.positions, signal )
visvis.plot( peaks, background_cutoff*np.ones(len(peaks)), ls=None, ms='+', mc='r', mw=20)
visvis.plot( [self.positions.min(), self.positions.max()], [background_cutoff, background_cutoff], lc='r', ls='--', ms=None)
visvis.legend( ["measured signal", "peaks found", "background cut-off"] )
visvis.ylabel( "total fluorescence")
visvis.xlabel( 'position (mm)')
示例15: setupAxes
def setupAxes(self):
"""
Sets up the axes initially. Shows a 2d view with a range based
on the sensor positions. Might want to give the user the option to set the range
in future releases.
The if statement is for when the sensors got switched.. which only
happens on 2 subjects, but totally messes up the axes view then.
"""
vv.clf()
self.axes = vv.gca()
self.axisLabeler = self.axes.axis
self.axes.cameraType = 3
self.axes.daspectAuto= False
#.SetLimits(#rangeX = (xmin,xmax),rangeY = (ymin,ymax), rangeZ = (zmin,zmax))
self.axisLabeler.showGrid = True