当前位置: 首页>>代码示例>>Python>>正文


Python visvis.figure函数代码示例

本文整理汇总了Python中visvis.figure函数的典型用法代码示例。如果您正苦于以下问题:Python figure函数的具体用法?Python figure怎么用?Python figure使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了figure函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self):

        # Create figure and axes
        vv.figure()
        self._a = a = vv.gca()
        vv.title("Hold mouse to draw lines. Use 'rgbcmyk' and '1-9' keys.")

        # Set axes
        a.SetLimits((0, 1), (0, 1))
        a.cameraType = "2d"
        a.daspectAuto = False
        a.axis.showGrid = True

        # Init variables needed during drawing
        self._active = None
        self._pp = Pointset(2)

        # Create null and empty line objects
        self._line1 = None
        self._line2 = vv.plot(vv.Pointset(2), ls="+", lc="c", lw="2", axes=a)

        # Bind to events
        a.eventMouseDown.Bind(self.OnDown)
        a.eventMouseUp.Bind(self.OnUp)
        a.eventMotion.Bind(self.OnMotion)
        a.eventKeyDown.Bind(self.OnKey)
开发者ID:gwdgithubnom,项目名称:visvis,代码行数:26,代码来源:drawing.py

示例2: plot

def plot(image):
    # ax = vv.gca()
    # ms = vv.Mesh(ax)
    logging.warning([image.shape, image.spacing])
    vol = image[:, :, :, 0]
    logging.warning([vol.min(), vol.max()])
    vol = util.normalize(vol, 'ADCm')
    logging.warning([vol.min(), vol.max()])
    vol = vv.Aarray(vol, image.spacing)

    cmap = None
    # cmap = vv.CM_VIRIDIS
    render_style = 'mip'
    # render_style = 'iso'
    # render_style = 'ray'
    # render_style = 'edgeray'
    # render_style = 'litray'

    vv.figure()
    vv.xlabel('x axis')
    vv.ylabel('y axis')
    vv.zlabel('z axis')

    a1 = vv.subplot(111)
    t1 = vv.volshow(vol, cm=cmap, renderStyle=render_style)
    t1.isoThreshold = 0.7
    vv.title(render_style)

    # a1.camera = a2.camera = a3.camera
    vv.ColormapEditor(a1)
开发者ID:jupito,项目名称:dwilib,代码行数:30,代码来源:vis.py

示例3: draw

    def draw( self ):
            """Draw data."""
            if len(self.fitResults) == 0:
                return
            
            # Make sure our figure is the active one
            vv.figure(self.fig.nr)
            
            if not hasattr( self, 'subplot1' ):
                self.subplot1 = vv.subplot(211)
                #self.subplot1.position = (30, 2, -32, -32)
                self.subplot2 = vv.subplot(212)
                #self.subplot1.position = (30, 2, -32, -32)

            

            a, ed = numpy.histogram(self.fitResults['tIndex'], self.Size[0]/6)
            print((float(numpy.diff(ed[:2]))))

            self.subplot1.MakeCurrent()
            vv.cla()
            vv.plot(ed[:-1], a/float(numpy.diff(ed[:2])), lc='b', lw=2)
            #self.subplot1.set_xticks([0, ed.max()])
            #self.subplot1.set_yticks([0, numpy.floor(a.max()/float(numpy.diff(ed[:2])))])
            self.subplot2.MakeCurrent()
            vv.cla()
            #cs =
            csa = numpy.cumsum(a)
            vv.plot(ed[:-1], csa/float(csa[-1]), lc='g', lw=2)
            #self.subplot2.set_xticks([0, ed.max()])
            #self.subplot2.set_yticks([0, a.sum()])

            self.fig.DrawNow()
            self.subplot1.position = (20, 2, -22, -32)
            self.subplot2.position = (20, 2, -22, -32)
开发者ID:RuralCat,项目名称:CLipPYME,代码行数:35,代码来源:progGraphVV.py

示例4: _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
开发者ID:MerDane,项目名称:pyKinectTools,代码行数:35,代码来源:VideoViewer.py

示例5: compareGraphsVisually

def compareGraphsVisually(graph1, graph2, fig=None):
    """ compareGraphsVisually(graph1, graph2, fig=None)
    Show the two graphs together in a figure. Matched nodes are
    indicated by lines between them.
    """
    
    # Get figure
    if isinstance(fig,int):
        fig = vv.figure(fig)
    elif fig is None:
        fig = vv.figure()
    
    # Prepare figure and axes
    fig.Clear()
    a = vv.gca()
    a.cameraType = '3d'; a.daspectAuto = False
    
    # Draw both graphs
    graph1.Draw(lc='b', mc='b')
    graph2.Draw(lc='r', mc='r')
    
    # Set the limits
    a.SetLimits()
    
    # Make a line from the edges
    pp = Pointset(3)
    for node in graph1:
        if hasattr(node, 'match') and node.match is not None:
            pp.append(node); pp.append(node.match)
    
    # Plot edges
    vv.plot(pp, lc='g', ls='+')
开发者ID:turapeach,项目名称:TOAK,代码行数:32,代码来源:graph.py

示例6: 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()
开发者ID:ThomasWalter,项目名称:scikit-image,代码行数:54,代码来源:visual_test.py

示例7: refresh

    def refresh(self):
        if len(self._value) > 1:
            vv.figure(self._fig.nr)

            a = vv.gca()
            view = a.GetView()
            a.Clear()
            vv.volshow3(self._value, renderStyle="mip", cm=self._colorMap)
            if not self._first:
                a = vv.gca()
                a.SetView(view)

            self._first = False
开发者ID:ColinBrosseau,项目名称:pyforms,代码行数:13,代码来源:ControlVisVisVolume.py

示例8: initControl

    def initControl(self):
        self._form = QtGui.QWidget();layout = QtGui.QVBoxLayout();layout.setMargin(0);self._form.setLayout( layout )
        self._app = vv.use('pyqt4')
        self._first=True

        Figure = self._app.GetFigureClass()
        self._fig = Figure(self._form)
        vv.figure(self._fig.nr)
        
        policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        widget = self._fig._widget
        widget.setSizePolicy(policy)

        layout.addWidget(widget)
开发者ID:sdcardoso,项目名称:pythonVideoAnnotator,代码行数:14,代码来源:ControlVisVisVolume.py

示例9: figure

def figure(figure=None):
    f = None
    
    if figure == None:
        f = vv.figure()
    else:
        try:
            f = vv.figure(figure)
        except:
            f = vv.figure() 

    f._widget.show()
    f._widget.raise_()
    return f
开发者ID:CALFEM,项目名称:calfem-python,代码行数:14,代码来源:vis.py

示例10: _call_new_item

 def _call_new_item(self, key, item_type, *args, **kwargs):
     if key in self.items:
         # an item with that key already exists
         # should raise an exception or warning
         pass
     else:
         # make this the current figure
         vv.figure(self.figure)
         # create a new dictionary of options for plotting
         plot_kwargs = dict()
         if 'line_width' in kwargs:
             value = kwargs.pop('line_width')
             plot_kwargs['lw'] = value
         if 'marker_width' in kwargs:
             value = kwargs.pop('marker_width')
             plot_kwargs['mw'] = value
         if 'marker_edge_width' in kwargs:
             value = kwargs.pop('marker_edge_width')
             plot_kwargs['mew'] = value
         if 'line_color' in kwargs:
             value = kwargs.pop('line_color')
             plot_kwargs['lc'] = value
         if 'marker_color' in kwargs:
             value = kwargs.pop('marker_color')
             plot_kwargs['mc'] = value
         if 'marker_edge_color' in kwargs:
             value = kwargs.pop('marker_edge_color')
             plot_kwargs['mec'] = value
         if 'line_style' in kwargs:
             value = kwargs.pop('line_style')
             plot_kwargs['ls'] = value
         if 'marker_style' in kwargs:
             value = kwargs.pop('marker_style')
             plot_kwargs['ms'] = value
         if 'adjust_axes' in kwargs:
             value = kwargs.pop('adjust_axes')
             plot_kwargs['axesAdjust'] = value
         # create the plot item
         if item_type == 'circular':
             data = pythics.lib.CircularArray(cols=2, length=kwargs['length'])
             item = vv.plot(np.array([]), np.array([]), axes=self.axes, **plot_kwargs)
         elif item_type == 'growable':
             data = pythics.lib.GrowableArray(cols=2, length=kwargs['length'])
             item = vv.plot(np.array([]), np.array([]), axes=self.axes, **plot_kwargs)
         else:
             data = np.array([])
             item = vv.plot(np.array([]), np.array([]), axes=self.axes, **plot_kwargs)
         self.items[key] = (item_type, data, item)
开发者ID:avelo,项目名称:Pythics,代码行数:48,代码来源:vv.py

示例11: initForm

    def initForm(self):
        self._form = QtGui.QWidget();layout = QtGui.QVBoxLayout();layout.setMargin(0);self._form.setLayout( layout )
        self._app = vv.use('pyqt4')
        self._app.Create()
        self._first=True

        Figure = self._app.GetFigureClass()
        self._fig = Figure(self._form)
        vv.figure(self._fig.nr)
        
        policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        widget = self._fig._widget
        widget.setSizePolicy(policy)
        widget.setMinimumSize(100, 100)

        layout.addWidget(widget)

        self._colorMap = vv.CM_AUTUMN
        self._colors_limits = None
开发者ID:AlfiyaZi,项目名称:pyforms,代码行数:19,代码来源:ControlVisVisVolume.py

示例12: show

def show(self):
    
    import visvis as vv
    
    # If there are many tests, make a selection
    if len(self._tests) > 1000:
        tests = random.sample(self._tests, 1000)
    else:
        tests = self._tests
    
    # Get ticks
    nn = [test[0] for test in tests]
    
    # Create figure
    vv.figure(1)
    vv.clf()
    
    # Prepare kwargs
    plotKwargsText = {'ms':'.', 'mc':'b', 'mw':5, 'ls':''}
    plotKwargsBin = {'ms':'.', 'mc':'r', 'mw':5, 'ls':''}
    
    # File size against number of elements
    vv.subplot(221)
    vv.plot(nn, [test[2][0] for test in tests], **plotKwargsText)
    vv.plot(nn, [test[2][1] for test in tests], **plotKwargsBin)
    vv.legend('text', 'binary')
    vv.title('File size')
    
    # Speed against number of elements
    vv.subplot(223)
    vv.plot(nn, [test[1][4] for test in tests], **plotKwargsText)
    vv.plot(nn, [test[1][6] for test in tests], **plotKwargsBin)
    vv.legend('text', 'binary')
    vv.title('Save time')
    
    # Speed (file) against number of elements
    vv.subplot(224)
    vv.plot(nn, [test[1][5] for test in tests], **plotKwargsText)
    vv.plot(nn, [test[1][7] for test in tests], **plotKwargsBin)
    vv.legend('text', 'binary')
    vv.title('Load time')
开发者ID:binaryannamolly,项目名称:visvis,代码行数:41,代码来源:test_random.py

示例13: set_plot_properties

 def set_plot_properties(self, **kwargs):
     # make this the current figure
     vv.figure(self.figure)
     if 'antialiasing' in kwargs:
         value = kwargs.pop('antialiasing')
         p_w.setAntialiasing(value)
     if 'background' in kwargs:
         value = kwargs.pop('background')
         p_w.setBackground(value)
     if 'aspect_ratio' in kwargs:
         # 'auto', 'equal', or a number
         value = kwargs.pop('aspect_ratio')
         if value == 'auto':
             self.axes.daspectAuto = True
         elif value == 'equal':
             self.axes.daspectAuto = False
             self.axes.daspect = (1, 1)
     if 'x_auto_scale' in kwargs:
         value = kwargs.pop('x_auto_scale')
     if 'y_auto_scale' in kwargs:
         value = kwargs.pop('y_auto_scale')
     if 'x_scale' in kwargs:
         value = kwargs.pop('x_scale')
     if 'y_scale' in kwargs:
         value = kwargs.pop('y_scale')
     if 'title' in kwargs:
         value = kwargs.pop('title')
         vv.title(value)
     if 'x_label' in kwargs:
         value = kwargs.pop('x_label')
         self.axes.axis.xLabel = value
     if 'y_label' in kwargs:
         value = kwargs.pop('y_label')
         self.axes.axis.yLabel = value
     if 'x_grid' in kwargs:
         value = kwargs.pop('x_grid')
         p_i.showGrid(x=value)
     if 'y_grid' in kwargs:
         value = kwargs.pop('y_grid')
         p_i.showGrid(y=value)
开发者ID:avelo,项目名称:Pythics,代码行数:40,代码来源:vv.py

示例14: crop3d

def crop3d(vol, fig=None):
    """ crop3d(vol, fig=None)
    Manually crop a volume. In the given figure (or a new figure if None),
    three axes are created that display the transversal, sagittal and 
    coronal MIPs (maximum intensity projection) of the volume. The user
    can then use the mouse to select a 3D range to crop the data to.
    """
    app = vv.use()
    
    # Create figure?    
    if fig is None:        
        fig = vv.figure()    
        figCleanup = True
    else:
        fig.Clear()
        figCleanup = False
    
    # Create three axes and a wibject to attach text labels to    
    a1 = vv.subplot(221)
    a2 = vv.subplot(222)
    a3 = vv.subplot(223)
    a4 = vv.Wibject(fig)
    a4.position = 0.5, 0.5, 0.5, 0.5
    
    # Set settings
    for a in [a1, a2, a3]:
        a.showAxis = False
    
    # Create cropper3D instance
    cropper3d = Cropper3D(vol, a1, a3, a2, a4)
    
    # Enter a mainloop
    while not cropper3d._finished:
        vv.processEvents()
        time.sleep(0.01)
    
    # Clean up figure (close if we opened it)
    fig.Clear()
    fig.DrawNow()
    if figCleanup:    
        fig.Destroy()
    
    # Obtain ranges
    rx = cropper3d._range_transversal._rangex
    ry = cropper3d._range_transversal._rangey
    rz = cropper3d._range_coronal._rangey
    
    # Perform crop
    vol2 = vol[rz.min:rz.max, ry.min:ry.max, rx.min:rx.max]
    
    # Done
    return vol2
开发者ID:binaryannamolly,项目名称:visvis,代码行数:52,代码来源:cropper.py

示例15: 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(im.min(), im.max())
		
		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.)

		fig.GetFigure().bgcolor = bgcolor
		fig.GetAxes().bgcolor = bgcolor



		fig.eventKeyUp.Bind(self.keyHandler)

		win = {'name':name, 'figure':fig, 'shape':dims, 'keyEvent':None}
		self.open_windows.append(win)

		return win
开发者ID:0x0all,项目名称:PythonSnippets,代码行数:36,代码来源:visvisExample.py


注:本文中的visvis.figure函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。