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


Python Figure.set_edgecolor方法代码示例

本文整理汇总了Python中matplotlib.figure.Figure.set_edgecolor方法的典型用法代码示例。如果您正苦于以下问题:Python Figure.set_edgecolor方法的具体用法?Python Figure.set_edgecolor怎么用?Python Figure.set_edgecolor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.figure.Figure的用法示例。


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

示例1: __init__

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_edgecolor [as 别名]
    def __init__(self, parent=None, width=5, height=4, dpi=100):
        fig = Figure(figsize=(width, height), dpi=dpi)

        # We want the axes cleared every time plot() is called
        self.axes = fig.add_subplot(1, 1, 1)

        self.axes.hold(False)

        FigureCanvas.__init__(self, fig)

        # self.figure
        self.setParent(parent)

        FigureCanvas.setSizePolicy(self,
                                   QtGui.QSizePolicy.Expanding,
                                   QtGui.QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)

        self._title = ''
        self.title_font = {'family': 'serif', 'fontsize': 10}
        self._title_size = 0
        self.figure.subplots_adjust(top=0.95, bottom=0.15)

        window_brush = self.window().palette().window()
        fig.set_facecolor(brush_to_color_tuple(window_brush))
        fig.set_edgecolor(brush_to_color_tuple(window_brush))
        self._active = False
开发者ID:Nikea,项目名称:nsls2_gui,代码行数:29,代码来源:dpc_gui.py

示例2: PlotPanel

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_edgecolor [as 别名]
class PlotPanel(wx.Panel):
    """The PlotPanel has a Figure and a Canvas. OnSize events simply set a 
    flag, and the actual resizing of the figure is triggered by an Idle event."""
    def __init__(self, parent, color=None, dpi=None, **kwargs):
        from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
        from matplotlib.figure import Figure

        self.parent = parent

        # initialize Panel
        if 'id' not in kwargs.keys():
            kwargs['id'] = wx.ID_ANY
        if 'style' not in kwargs.keys():
            kwargs['style'] = wx.NO_FULL_REPAINT_ON_RESIZE
        wx.Panel.__init__(self, parent, **kwargs)

        # initialize matplotlib stuff
        self.figure = Figure(None, dpi)
        self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
        self.SetColor(color) 

        self._SetSize()
        self.initial_draw()

        self._resizeflag = False
        self._redrawflag = False

        self.Bind(wx.EVT_IDLE, self._onIdle)
        self.Bind(wx.EVT_SIZE, self._onSize)

    def SetColor(self, rgbtuple=None):
        """Set figure and canvas colours to be the same."""
        if rgbtuple is None:
            rgbtuple = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE).Get()
        clr = [c/255. for c in rgbtuple]
        self.figure.set_facecolor(clr)
        self.figure.set_edgecolor(clr)
        self.canvas.SetBackgroundColour(wx.Colour(*rgbtuple))

    def _onSize(self, event):
        self._resizeflag = True

    def _onIdle(self, evt):
        with draw_lock:
            if self._resizeflag:
                self._resizeflag = False
                self._SetSize()
            if self._redrawflag:
                self._redrawflag = False
                self.canvas.draw()

    def _SetSize(self):
        # When drawing from another thread, I think this may need a lock
        pixels = tuple(self.parent.GetClientSize())
        self.SetSize(pixels)
        self.canvas.SetSize(pixels)
        self.figure.set_size_inches(float(pixels[0])/self.figure.get_dpi(),
                                     float(pixels[1])/self.figure.get_dpi())

    def initial_draw(self): pass # abstract, to be overridden by child classes
开发者ID:mandad,项目名称:svplot,代码行数:62,代码来源:realtime_sv.py

示例3: PlotPanel

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_edgecolor [as 别名]
class PlotPanel(wx.Panel):
    """
    The PlotPanel has a Figure and a Canvas. OnSize events simply set a 
    flag, and the actual resizing of the figure is triggered by an Idle event.
    """

    def __init__(self, parent, obj_id):
        # initialize Panel
        wx.Panel.__init__(self, parent, obj_id)

        # initialize matplotlib stuff
        self.figure = Figure(None, None)
        self.canvas = FigureCanvasWxAgg(self, wx.ID_ANY, self.figure)
        rgbtuple = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE).Get()
        clr = [c / 255.0 for c in rgbtuple]
        self.figure.set_facecolor(clr)
        self.figure.set_edgecolor(clr)
        self.canvas.SetBackgroundColour(wx.Colour(*rgbtuple))

        self.Bind(wx.EVT_SIZE, self._on_size)

    def _on_size(self, event):
        self._set_size()

    def _set_size(self):
        pixels = tuple(self.GetClientSize())
        self.SetSize(pixels)
        self.canvas.SetSize(pixels)
        self.figure.set_size_inches(float(pixels[0]) / self.figure.get_dpi(), float(pixels[1]) / self.figure.get_dpi())

    def draw(self):
        pass  # abstract, to be overridden by child classes
开发者ID:hgfalling,项目名称:pyquest,代码行数:34,代码来源:tree_viewer.py

示例4: PlotPanel

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_edgecolor [as 别名]
class PlotPanel (wx.Panel):
    """
    PlotPanel class taken from http://www.scipy.org/Matplotlib_figure_in_a_wx_panel

    The PlotPanel has a Figure and a Canvas. OnSize events simply set a 
    flag, and the actual resizing of the figure is triggered by an Idle event."""

    def __init__(self, parent, color=None, dpi=None, **kwargs):
        from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
        from matplotlib.figure import Figure
        self.parent = parent
        # initialize Panel
        if 'id' not in list(kwargs.keys()):
            kwargs['id'] = wx.ID_ANY
        if 'style' not in list(kwargs.keys()):
            kwargs['style'] = wx.NO_FULL_REPAINT_ON_RESIZE
        wx.Panel.__init__(self, parent, **kwargs)

        # initialize matplotlib stuff
        self.figure = Figure(None, dpi)
        self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
        self.SetColor(color)

        self._SetSize()
        self.draw()

        self._resizeflag = False

        self.Bind(wx.EVT_IDLE, self._onIdle)
        self.Bind(wx.EVT_SIZE, self._onSize)

    def SetColor(self, rgbtuple=None):
        """Set figure and canvas colours to be the same."""
        if rgbtuple is None:
            rgbtuple = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE).Get()
        clr = [c / 255. for c in rgbtuple]
        self.figure.set_facecolor(clr)
        self.figure.set_edgecolor(clr)
        self.canvas.SetBackgroundColour(wx.Colour(*rgbtuple))

    def _onSize(self, event):
        self._resizeflag = True

    def _onIdle(self, evt):
        if self._resizeflag:
            self._resizeflag = False
            self._SetSize()

    def _SetSize(self):
        pixels = tuple(self.parent.GetClientSize())
        self.SetSize(pixels)
        self.canvas.SetSize(pixels)
        self.figure.set_size_inches(float(pixels[0]) / self.figure.get_dpi(),
                                    float(pixels[1]) / self.figure.get_dpi())

    def draw(self):
        # abstract, to be overridden by child classes
        raise NotImplementedError(
            "Abstract method - must be defined in subclass")
开发者ID:paalge,项目名称:pysces-asi,代码行数:61,代码来源:GUI.py

示例5: WXMatPlotLibPanel

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_edgecolor [as 别名]
class WXMatPlotLibPanel( wx.Panel ):
    def __init__( self, parent, color=None, dpi=None, **kwargs ):
        from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
        from matplotlib.figure import Figure

        # initialize Panel
        if 'id' not in kwargs.keys():
            kwargs['id'] = wx.ID_ANY
        if 'style' not in kwargs.keys():
            kwargs['style'] = wx.NO_FULL_REPAINT_ON_RESIZE
        wx.Panel.__init__( self, parent, **kwargs )

        # initialize matplotlib stuff
        self.figure = Figure( None, dpi )
        self.canvas = FigureCanvasWxAgg( self, -1, self.figure )
        #self.SetColor( color )

        self._SetSize()
        self.draw()

        self._resizeflag = False

        self.Bind(wx.EVT_IDLE, self._onIdle)
        self.Bind(wx.EVT_SIZE, self._onSize)

    def SetColor( self, rgbtuple=None ):
        """Set figure and canvas colours to be the same."""
        if rgbtuple is None:
            rgbtuple = wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNFACE ).Get()
        clr = [c/255. for c in rgbtuple]
        self.figure.set_facecolor( clr )
        self.figure.set_edgecolor( clr )
        self.canvas.SetBackgroundColour( wx.Colour( *rgbtuple ) )

    def _onSize( self, event ):
        self._resizeflag = True

    def _onIdle( self, evt ):
        if self._resizeflag:
            self._resizeflag = False
            self._SetSize()

    def _SetSize( self ):
        pixels = tuple( self.parent.GetClientSize() )
        self.SetSize( pixels )
        self.canvas.SetSize( pixels )
        self.figure.set_size_inches( float( pixels[0] )/self.figure.get_dpi(),
                                     float( pixels[1] )/self.figure.get_dpi() )

    def draw(self): pass # abstract, to be overridden by child classes
开发者ID:gt-ros-pkg,项目名称:hrl,代码行数:52,代码来源:joint_state_viz.py

示例6: PlotPanel

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_edgecolor [as 别名]
class PlotPanel (wx.Panel):
    """The PlotPanel has a Figure and a Canvas. OnSize events simply set a
flag, and the actual resizing of the figure is triggered by an Idle event."""
    def __init__( self, parent, color=None, dpi=None, **kwargs ):
        from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
        from matplotlib.figure import Figure

        # initialize Panel
        if 'id' not in kwargs.keys():
            kwargs['id'] = wx.ID_ANY
        if 'style' not in kwargs.keys():
            kwargs['style'] = wx.NO_FULL_REPAINT_ON_RESIZE
        wx.Panel.__init__( self, parent, **kwargs )

        # initialize matplotlib stuff
        self.figure = Figure( None, dpi )
        self.canvas = FigureCanvasWxAgg( self, -1, self.figure )
        self.SetColor( color )

        self._resizeflag = False

        self.Bind(wx.EVT_IDLE, self._onIdle)
        self.Bind(wx.EVT_SIZE, self._onSize)

    def SetColor( self, rgbtuple=None ):
        """Set figure and canvas colours to be the same."""
        if rgbtuple is None:
            rgbtuple = wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNFACE ).Get()
        clr = [c/255. for c in rgbtuple]
        self.figure.set_facecolor( clr )
        self.figure.set_edgecolor( clr )
        self.canvas.SetBackgroundColour( wx.Colour( *rgbtuple ) )

    def _onSize( self, event ):
        self._resizeflag = True

    def _onIdle( self, evt ):
        if self._resizeflag:
            self._resizeflag = False
            self.canvas.SetSize( self.GetSize() )

    def draw(self, *args, **kwargs):
        pass # abstract, to be overridden by child classes
        if not hasattr( self, 'subplot' ):
            self.subplot = self.figure.add_subplot( 111 )
        clr = [0.5, 0.5, 0.5]
        self.subplot.plot( [1,2,3,4], [-5,12,3,45], color=clr )
开发者ID:,项目名称:,代码行数:49,代码来源:

示例7: marker_image

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_edgecolor [as 别名]
def marker_image(path, size, trans,
                 edgecolor='k', facecolor = 'b',
                 edgewidth= 1.0):


   
   fig = Figure(figsize=((size*2+1)/72., (size*2+1)/72.), dpi = 72)


   #fig.set_edgecolor([1,1,1,0])
   #fig.set_facecolor([1,1,1,0])
   fig.set_edgecolor([0,0,0,0])
   fig.set_facecolor([0,0,0,0])
   fig.patch.set_alpha(0.0)   
   fig.clf()
   fig.frameon = False
   ax = fig.add_subplot(111)
   ax.set_position((0,0,1,1))      
   ed=ax.transAxes.transform([(0,0), (1,1)])

   path = trans.transform_path(path)
   patch = patches.PathPatch(path, facecolor=facecolor, edgecolor=edgecolor,
                             lw=edgewidth)
   ax.patch.set_facecolor([0,0,0,0])
   ax.patch.set_edgecolor([0,0,0,0])
   ax.patch.set_alpha(0.0)
   ax.add_patch(patch)
   ax.set_xlim(-1,1)
   ax.set_ylim(-1,1)
   ax.tick_params(length=0)

   ax.set_axis_off()
   canvas = FigureCanvasAgg(fig)
   buff, size = canvas.print_to_buffer()
   
   im =  np.fromstring(buff, np.uint8).reshape(size[1], size[0], -1)
   #idx = np.where(im[:,:,-1] == 0)
   #im[:,:,0][idx] = 0
   #im[:,:,1][idx] = 0
   #im[:,:,2][idx] = 0   
   return im
开发者ID:piScope,项目名称:piScope,代码行数:43,代码来源:marker_image.py

示例8: Grafico

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_edgecolor [as 别名]
class Grafico(wx.Panel):

    altura_grafico = 340
    largura_grafico = 550

    def __init__(self, pai, posicao, labely, labelx):
        wx.Panel.__init__(self, pai, -1, posicao, size=(Grafico.largura_grafico, Grafico.altura_grafico))

        self.labelx = labelx
        self.labely = labely

        self.inicia()

    #funcao que inicia os gráficos
    def inicia(self):
        #cria uma nova figura que vai conter o grafico
        self.figura = Figure()

        #cria um canvas para imagem
        self.canvas = FigureCanvas(self, -1, self.figura)

        #cria um só plot
        self.eixos = self.figura.add_subplot(111)
        self.eixos.set_ylabel(self.labely)
        self.eixos.set_xlabel(self.labelx)

        self.canvas.SetSize((Grafico.largura_grafico,Grafico.altura_grafico))

        self.figura.set_edgecolor("m")

    #desenha os pontos x e y. Dois vetores que devem ter o mesmo tamanho
    #os vertices serão (pontosX[n], pontosY[n])
    def desenha(self, pontosX, pontosY):
        #adiciona os pontos x e y no grafico
        self.eixos.plot(pontosX, pontosY)
        self.canvas.draw()

    #limpa o grafico
    def limpa(self):
        self.inicia()
开发者ID:temdisponivel,项目名称:ic,代码行数:42,代码来源:interface_usuario.py

示例9: PlotPanel

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_edgecolor [as 别名]
class PlotPanel(wx.Panel):
    """
    The PlotPanel has a Figure and a Canvas. 
    """
    def __init__(self,parent,obj_id):
        # initialize Panel
        wx.Panel.__init__(self,parent,obj_id)

        # initialize matplotlib stuff
        self.figure = Figure(None,None,tight_layout=True)
        self.canvas = FigureCanvasWxAgg(self,wx.ID_ANY,self.figure)
        rgbtuple = wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNFACE ).Get()
        clr = [c/255. for c in rgbtuple]
        self.figure.set_facecolor( clr )
        self.figure.set_edgecolor( clr )
        
        self.sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer.Add(self.canvas,1,wx.EXPAND)
        self.SetSizer(self.sizer)

    def draw(self): 
        pass # abstract, to be overridden by child classes
开发者ID:hgfalling,项目名称:pyquest_work,代码行数:24,代码来源:wxplot_util.py

示例10: TransformCanvasPanel

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_edgecolor [as 别名]
class TransformCanvasPanel(FigureCanvas):
    """A panel that extends the matplotlib class FigureCanvas for plotting the corresponding points from the two coordinate systems, and their transforms"""
    def __init__(self, parent, **kwargs):
        """keyword the same as standard init function for a FigureCanvas"""
        self.figure = Figure(figsize=(6,4))
        FigureCanvas.__init__(self, parent, -1, self.figure, **kwargs)
        self.canvas = self.figure.canvas
        #format the appearance
        self.figure.set_facecolor((1,1,1))
        self.figure.set_edgecolor((1,1,1))
        self.canvas.SetBackgroundColour('black')   
        
        #add subplots for various things
        self.fromplot = self.figure.add_axes([.05,.05,.45,.92])
        self.toplot = self.figure.add_axes([.55,.05,.45,.92])
        self.fromplot.set_axis_bgcolor('black')
        self.toplot.set_axis_bgcolor('black')
        self.fromplot.yaxis.set_major_locator(LooseMaxNLocator(nbins=5,margin=.125))
        self.fromplot.xaxis.set_major_locator(LooseMaxNLocator(nbins=5,margin=.125))
        #self.toplot.yaxis.set_major_locator(LooseMaxNLocator(nbins=5,margin=.0125))
        #self.toplot.xaxis.set_major_locator(LooseMaxNLocator(nbins=5,margin=.0125))
        
    def plot_points_in_from(self,xx,yy,color='black'):
        self.from_points=Line2D(xx,yy,marker='x',markersize=7,markeredgewidth=1.5,markeredgecolor=color)
        self.fromplot.add_line(self.pointLine2D)
    
    def plot_trans_points(self,xx,yy,color='black'):
        self.trans_points=Line2D(xx,yy,marker='x',markersize=7,markeredgewidth=1.5,markeredgecolor=color)
        self.toplot.add_line(self.trans_points)
        for i in range(len(xx)):
            numTxt = self.toplot.text(xx[i],yy[i],str(i)+"  ",color='g',weight='bold') 
            numTxt.set_visible(True)
            numTxt.set_horizontalalignment('left')
        self.toplot.relim()
        self.toplot.autoscale_view()
        self.draw()
开发者ID:berl,项目名称:MosaicPlannerLive,代码行数:38,代码来源:Transform.py

示例11: DensityPanel

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_edgecolor [as 别名]
class DensityPanel(FigureCanvasWxAgg):
    def __init__(self, parent, **kwargs):
        self.figure = Figure()
        FigureCanvasWxAgg.__init__(self, parent, -1, self.figure, **kwargs)
        self.canvas = self.figure.canvas
        self.SetMinSize((100,100))
        self.figure.set_facecolor((1,1,1))
        self.figure.set_edgecolor((1,1,1))
        self.canvas.SetBackgroundColour('white')
        self.subplot = self.figure.add_subplot(111)
        self.gate_helper = GatingHelper(self.subplot, self)

        self.navtoolbar = None
        self.point_list = []
        self.gridsize = 50
        self.cb = None
        self.x_scale = LINEAR_SCALE
        self.y_scale = LINEAR_SCALE
        self.color_scale = None
        self.x_label = ''
        self.y_label = ''
        self.cmap ='jet'
        
        self.canvas.mpl_connect('button_release_event', self.on_release)
    
    def setpointslists(self, points):
        self.subplot.clear()
        self.point_list = points        
        plot_pts = np.array(points).astype(float)
        
        if self.x_scale == LOG_SCALE:
            plot_pts = plot_pts[(plot_pts[:,0]>0)]
        if self.y_scale == LOG_SCALE:
            plot_pts = plot_pts[(plot_pts[:,1]>0)]
        
        hb = self.subplot.hexbin(plot_pts[:, 0], plot_pts[:, 1], 
                                 gridsize=self.gridsize,
                                 xscale=self.x_scale,
                                 yscale=self.y_scale,
                                 bins=self.color_scale,
                                 cmap=matplotlib.cm.get_cmap(self.cmap))
        
        if self.cb:
            # Remove the existing colorbar and reclaim the space so when we add
            # a colorbar to the new hexbin subplot, it doesn't get indented.
            self.figure.delaxes(self.figure.axes[1])
            self.figure.subplots_adjust(right=0.90)
        self.cb = self.figure.colorbar(hb)
        if self.color_scale==LOG_SCALE:
            self.cb.set_label('log10(N)')
        
        self.subplot.set_xlabel(self.x_label)
        self.subplot.set_ylabel(self.y_label)
        
        xmin = np.nanmin(plot_pts[:,0])
        xmax = np.nanmax(plot_pts[:,0])
        ymin = np.nanmin(plot_pts[:,1])
        ymax = np.nanmax(plot_pts[:,1])

        # Pad all sides
        if self.x_scale==LOG_SCALE:
            xmin = xmin/1.5
            xmax = xmax*1.5
        else:
            xmin = xmin-(xmax-xmin)/20.
            xmax = xmax+(xmax-xmin)/20.
            
        if self.y_scale==LOG_SCALE:
            ymin = ymin/1.5
            ymax = ymax*1.5
        else:
            ymin = ymin-(ymax-ymin)/20.
            ymax = ymax+(ymax-ymin)/20.

        self.subplot.axis([xmin, xmax, ymin, ymax])
    
        self.reset_toolbar()
    
    def getpointslists(self):
        return self.point_list
    
    def setgridsize(self, gridsize):
        self.gridsize = gridsize

    def set_x_scale(self, scale):
        self.x_scale = scale
    
    def set_y_scale(self, scale):
        self.y_scale = scale
        
    def set_color_scale(self, scale):
        if scale==LINEAR_SCALE:
            scale = None
        self.color_scale = scale

    def set_x_label(self, label):
        self.x_label = label
    
    def set_y_label(self, label):
        self.y_label = label
#.........这里部分代码省略.........
开发者ID:daviddao,项目名称:CellProfiler-Analyst,代码行数:103,代码来源:density.py

示例12: plotHist

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_edgecolor [as 别名]

#.........这里部分代码省略.........
        # Create the navigation toolbar, tied to the canvas
        self.toolbar = NavigationToolbar(self.canvas, True)
        self.toolbar.Realize()
        self.figure.tight_layout()

        self.setColor("WHITE")
        self.canvas.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.NORMAL,
                                    False, u'Tahoma'))
        self.canvas.draw()
        self._init_sizers()
        self.hist = []
        self.bins = 50


    def changeNumOfBins(self, bins):
        self.bins = bins
        self.updatePlot()


    def clear(self):
        self.figure.clear()
        self.hist = []



    def gridSize(self, cells):
        rows = 1
        cols = 1
        while rows * cols < cells:
            if rows == cols:
                cols = cols + 1
            else:
                rows = rows + 1
        return rows, cols

    def textSize(self, cells):
        wrap = 50
        wrap = wrap - (cells * 3)
        text = 20 - cells
        return wrap, text

    def Plot(self, seriesPlotInfo):
        self.seriesPlotInfo = seriesPlotInfo
        self.updatePlot()

    def updatePlot(self):
        self.clear()
        count = self.seriesPlotInfo.count()
        rows, cols = self.gridSize(count)
        self.plots = []
        i = 1
        for oneSeries in self.seriesPlotInfo.getAllSeries():
            self.plots.append(self.figure.add_subplot(repr(rows) + repr(cols) + repr(i)))

            wrap, text = self.textSize(count)
            self.plots[i - 1].set_xlabel("\n".join(textwrap.wrap(oneSeries.variableName, wrap)))
            self.plots[i - 1].set_ylabel("Number of Observations")

            self.canvas.SetFont(wx.Font(text, wx.SWISS, wx.NORMAL, wx.NORMAL,
                                        False, u'Tahoma'))

            #self.plots[i - 1].set_title(
            # "\n".join(textwrap.wrap(oneSeries.siteName + " " + oneSeries.variableName, wrap)))
            self.plots[i - 1].set_title("\n".join(textwrap.wrap(oneSeries.siteName, wrap)))


            #print "oneSeries.dataTable:", oneSeries.dataTable
            if len(oneSeries.dataTable) >0:
                self.hist.append(self.plots[i - 1].hist(
                        [x[0] for x in oneSeries.dataTable if x[0] <> oneSeries.noDataValue], bins=self.bins, normed=False, facecolor=oneSeries.color,
                        label=oneSeries.siteName + " " + oneSeries.variableName
                    )
                )
            i += 1

        left = 0.125  # the left side of the subplots of the figure
        right = 0.9  # the right side of the subplots of the figure
        bottom = 0.51  # the bottom of the subplots of the figure
        top = 1.2  # the top of the subplots of the figure
        wspace = .8  # the amount of width reserved for blank space between subplots
        hspace = .8  # the amount of height reserved for white space between subplots
        self.figure.subplots_adjust(
            left=left, bottom=bottom, right=right, top=top, wspace=wspace, hspace=hspace
        )

        if len(self.hist)>0:
            self.figure.tight_layout()

        self.canvas.draw()


    def setColor(self, color):
        """Set figure and canvas colours to be the same."""
        self.figure.set_facecolor(color)
        self.figure.set_edgecolor(color)
        self.canvas.SetBackgroundColour(color)


    def __init__(self, parent, id, pos, size, style, name):
        self._init_ctrls(parent)
开发者ID:elmachine8,项目名称:ODMToolsPython,代码行数:104,代码来源:plotHistogram.py

示例13: plotHist

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_edgecolor [as 别名]

#.........这里部分代码省略.........

    def _init_ctrls(self, prnt):
        # matplotlib.figure.Figure.__init__(self)
        wx.Panel.__init__(self, prnt, -1)

        self.figure = Figure()

        plot = self.figure.add_subplot(111)
        plot.set_title("No Data To Plot")

        self.canvas = FigCanvas(self, -1, self.figure)
        # Create the navigation toolbar, tied to the canvas
        self.toolbar = NavigationToolbar(self.canvas, True)
        self.toolbar.Realize()
        self.figure.tight_layout()

        self.setColor("WHITE")
        self.canvas.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.NORMAL,
                                    False, u'Tahoma'))
        self.canvas.draw()
        self._init_sizers()

        self.bins = 50


    def changeNumOfBins(self, bins):
        self.bins = bins
        self.updatePlot()


    def clear(self):
        self.figure.clear()
        # plt.clear()


    def gridSize(self, cells):
        rows = 1
        cols = 1
        while rows * cols < cells:
            if rows == cols:
                cols = cols + 1
            else:
                rows = rows + 1
        return rows, cols

    def textSize(self, cells):
        wrap = 50
        wrap = wrap - (cells * 3)
        text = 20 - cells
        return wrap, text

    def Plot(self, seriesPlotInfo):
        self.seriesPlotInfo = seriesPlotInfo
        self.updatePlot()

    def updatePlot(self):
        self.clear()
        rows, cols = self.gridSize(self.seriesPlotInfo.count())
        logger.debug("Rows: %s, cols: %s" % (rows,cols))

        i = 1
        for oneSeries in self.seriesPlotInfo.getAllSeries():
            if len(oneSeries.dataTable) > 0:
                self._createPlot(oneSeries, rows, cols, i)
                i += 1

        #self.figure.tight_layout()
        self.canvas.draw()


    def _createPlot(self, oneSeries, rows, cols, index):
        ax = self.figure.add_subplot(repr(rows) + repr(cols) + repr(index))

        logger.debug("HISTOGRAM: %s"% ax)

        # oneSeries.filteredData.hist(ax= ax, color='k', alpha=0.5, bins=50)

        his = oneSeries.dataTable.hist(column="DataValue", ax=ax, bins=self.bins,
                                          facecolor=oneSeries.color,
                                          label=oneSeries.siteName + " " + oneSeries.variableName,
                                          grid=False)

        wrap, text = self.textSize(self.seriesPlotInfo.count())
        ax.set_xlabel("\n".join(textwrap.wrap(oneSeries.variableName, wrap)))
        ax.set_ylabel("Number of Observations")

        self.canvas.SetFont(wx.Font(text, wx.SWISS, wx.NORMAL, wx.NORMAL,
                                    False, u'Tahoma'))
        ax.set_title("\n".join(textwrap.wrap(oneSeries.siteName, wrap)))


    def setColor(self, color):
        """Set figure and canvas colours to be the same."""
        self.figure.set_facecolor(color)
        self.figure.set_edgecolor(color)
        self.canvas.SetBackgroundColour(color)


    def __init__(self, parent, id, pos, size, style, name):
        self._init_ctrls(parent)
开发者ID:fl0f,项目名称:ODMToolsPython,代码行数:104,代码来源:plotHistogram.py

示例14: PlotPanel

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_edgecolor [as 别名]
class PlotPanel(wx.Panel):
    ''' Base class for the plotting in GenX - all the basic functionallity
        should be implemented in this class. The plots should be derived from
        this class. These classes should implement an update method to update
        the plots. 
    '''
    def __init__(self, parent, id = -1, color = None, dpi = None
            , style = wx.NO_FULL_REPAINT_ON_RESIZE|wx.EXPAND|wx.ALL
            , config = None, config_name = '', **kwargs):
        
        wx.Panel.__init__(self,parent, id = id, style = style, **kwargs)
        
        self.parent = parent
        self.callback_window = self
        self.config = config
        self.config_name = config_name
        self.figure = Figure(None,dpi)
        self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
        self.canvas.SetExtraStyle(wx.EXPAND)
        self.SetColor(color)
        self.Bind(wx.EVT_IDLE, self._onIdle)
        self.Bind(wx.EVT_SIZE, self._onSize)
        self._resizeflag = True
        self.print_size = (15./2.54, 12./2.54)
        #self._SetSize()
        
        # Flags and bindings for zooming
        self.zoom = False
        self.zooming = False
        self.scale = 'linear'
        self.autoscale = True
        
        
        self.canvas.Bind(wx.EVT_LEFT_DOWN, self.OnLeftMouseButtonDown)
        self.canvas.Bind(wx.EVT_LEFT_UP, self.OnLeftMouseButtonUp)
        self.canvas.Bind(wx.EVT_MOTION, self.OnMouseMove)
        self.canvas.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDblClick)
        self.canvas.Bind(wx.EVT_RIGHT_UP, self.OnContextMenu)
        
        cursor = wx.StockCursor(wx.CURSOR_CROSS)
        self.canvas.SetCursor(cursor)
        self.old_scale_state = True
        self.ax = None

        # Init printout stuff
        self.fig_printer = FigurePrinter(self)

        # Create the drawing bitmap
        self.bitmap =wx.EmptyBitmap(1, 1)
#        DEBUG_MSG("__init__() - bitmap w:%d h:%d" % (w,h), 2, self)
        self._isDrawn = False
    
    def SetColor(self, rgbtuple=None):
        ''' Set the figure and canvas color to be the same '''
        if not rgbtuple:
            rgbtuple = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE).Get()
        col = [c/255. for c in rgbtuple]
        self.figure.set_facecolor(col)
        self.figure.set_edgecolor(col)
        self.canvas.SetBackgroundColour(wx.Colour(*rgbtuple))
        
    def _onSize(self, evt):
        self._resizeflag = True
        self._SetSize()
        #self.canvas.draw(repaint = False)
        
    def _onIdle(self, evt):
        if self._resizeflag:
            self._resizeflag = False
            self._SetSize()
            #self.canvas.gui_repaint(drawDC = wx.PaintDC(self))

            
    def _SetSize(self, pixels = None):
        ''' This method can be called to force the Plot to be a desired 
            size which defaults to the ClientSize of the Panel.
        '''
        if not pixels:
            pixels = self.GetClientSize()

        self.canvas.SetSize(pixels)
        #self.figure.set_size_inches(pixels[0]/self.figure.get_dpi()
        #, pixels[1]/self.figure.get_dpi())
    
    def ReadConfig(self):
        '''ReadConfig(self) --> None
        
        Reads in the config file
        '''
        bool_items = ['zoom', 'autoscale']
        bool_func = [self.SetZoom, self.SetAutoScale]
        
        if not self.config:
            return
        
        
        vals = []
        for index in range(len(bool_items)):
            try:
                val = self.config.get_boolean(self.config_name,\
#.........这里部分代码省略.........
开发者ID:jackey-qiu,项目名称:genx,代码行数:103,代码来源:plotpanel.py

示例15: GraphFrame

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_edgecolor [as 别名]
class GraphFrame(wx.Frame):
    def __init__(self, parent, style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE | wx.FRAME_FLOAT_ON_PARENT):

        global enabled
        global mplImported

        self.legendFix = False
        if not enabled:
            return

        try:
            import matplotlib as mpl
            if not mplImported:
                mpl.use('wxagg')
            from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas
            from matplotlib.figure import Figure
            enabled = True
            if mpl.__version__[0] != "1":
                print "pyfa: Found matplotlib version ",mpl.__version__, " - activating OVER9000 workarounds"
                print "pyfa: Recommended minimum matplotlib version is 1.0.0"
                self.legendFix = True
        except:
            print "Problems importing matplotlib; continuing without graphs"
            enabled = False
            return

        mplImported = True

        wx.Frame.__init__(self, parent, title=u"pyfa: Graph Generator", style=style, size=(520, 390))

        i = wx.IconFromBitmap(bitmapLoader.getBitmap("graphs_small", "icons"))
        self.SetIcon(i)
        self.mainFrame = gui.mainFrame.MainFrame.getInstance()
        self.CreateStatusBar()

        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(self.mainSizer)

        sFit = service.Fit.getInstance()
        fit = sFit.getFit(self.mainFrame.getActiveFit())
        self.fits = [fit] if fit is not None else []
        self.fitList = FitList(self)
        self.fitList.SetMinSize((270, -1))

        self.fitList.fitList.update(self.fits)

        self.graphSelection = wx.Choice(self, wx.ID_ANY, style=0)
        self.mainSizer.Add(self.graphSelection, 0, wx.EXPAND)

        self.figure = Figure(figsize=(4, 3))

        rgbtuple = wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNFACE ).Get()
        clr = [c/255. for c in rgbtuple]
        self.figure.set_facecolor( clr )
        self.figure.set_edgecolor( clr )

        self.canvas = Canvas(self, -1, self.figure)
        self.canvas.SetBackgroundColour( wx.Colour( *rgbtuple ) )

        self.subplot = self.figure.add_subplot(111)
        self.subplot.grid(True)

        self.mainSizer.Add(self.canvas, 1, wx.EXPAND)
        self.mainSizer.Add(wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ), 0 , wx.EXPAND)

        self.gridPanel = wx.Panel(self)
        self.mainSizer.Add(self.gridPanel, 0, wx.EXPAND)

        dummyBox = wx.BoxSizer(wx.VERTICAL)
        self.gridPanel.SetSizer(dummyBox)

        self.gridSizer = wx.FlexGridSizer(0, 4)
        self.gridSizer.AddGrowableCol(1)
        dummyBox.Add(self.gridSizer, 0, wx.EXPAND)

        for view in Graph.views:
            view = view()
            self.graphSelection.Append(view.name, view)

        self.graphSelection.SetSelection(0)
        self.fields = {}
        self.select(0)
        self.sl1 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
        self.mainSizer.Add(self.sl1,0, wx.EXPAND)
        self.mainSizer.Add(self.fitList, 0, wx.EXPAND)

        self.fitList.fitList.Bind(wx.EVT_LEFT_DCLICK, self.removeItem)
        self.mainFrame.Bind(GE.FIT_CHANGED, self.draw)
        self.Bind(wx.EVT_CLOSE, self.close)

        self.Fit()
        self.SetMinSize(self.GetSize())

    def handleDrag(self, type, fitID):
        if type == "fit":
            self.AppendFitToList(fitID)

    def close(self, event):
        self.fitList.fitList.Unbind(wx.EVT_LEFT_DCLICK, handler=self.removeItem)
        self.mainFrame.Unbind(GE.FIT_CHANGED, handler=self.draw)
#.........这里部分代码省略.........
开发者ID:Bashta,项目名称:Pyfa,代码行数:103,代码来源:graphFrame.py


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