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


Python Figure.text方法代码示例

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


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

示例1: check_and_plot

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import text [as 别名]
    def check_and_plot(self, A_nn, A0_nn, digits, keywords=''):
        # Construct fingerprint of input matrices for comparison
        fingerprint = np.array([md5_array(A_nn, numeric=True),
                                md5_array(A0_nn, numeric=True)])

        # Compare fingerprints across all processors
        fingerprints = np.empty((world.size, 2), np.int64)
        world.all_gather(fingerprint, fingerprints)
        if fingerprints.ptp(0).any():
            raise RuntimeError('Distributed matrices are not identical!')

        # If assertion fails, catch temporarily while plotting, then re-raise
        try:
            self.assertAlmostEqual(np.abs(A_nn-A0_nn).max(), 0, digits)
        except AssertionError:
            if world.rank == 0 and mpl is not None:
                from matplotlib.figure import Figure
                fig = Figure()
                ax = fig.add_axes([0.0, 0.1, 1.0, 0.83])
                ax.set_title(self.__class__.__name__)
                im = ax.imshow(np.abs(A_nn-A0_nn), interpolation='nearest')
                fig.colorbar(im)
                fig.text(0.5, 0.05, 'Keywords: ' + keywords, \
                    horizontalalignment='center', verticalalignment='top')

                from matplotlib.backends.backend_agg import FigureCanvasAgg
                img = 'ut_hsops_%s_%s.png' % (self.__class__.__name__, \
                    '_'.join(keywords.split(',')))
                FigureCanvasAgg(fig).print_figure(img.lower(), dpi=90)
            raise
开发者ID:ryancoleman,项目名称:lotsofcoresbook2code,代码行数:32,代码来源:ut_hsops.py

示例2: eq

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import text [as 别名]
def eq(code, **kwargs):
	from matplotlib.figure import Figure
	if "horizontalalignment" not in kwargs:
		kwargs["horizontalalignment"] = "center"
	if "verticalalignment" not in kwargs:
		kwargs["verticalalignment"] = "center"
	f = Figure(frameon=False)
	f.text(0.5, 0.5, code, **kwargs)
	return f
开发者ID:Lunderberg,项目名称:pyspread,代码行数:11,代码来源:macro_equation.py

示例3: test_unicode_won

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import text [as 别名]
def test_unicode_won():
    fig = Figure()
    fig.text(.5, .5, r'\textwon', usetex=True)

    with BytesIO() as fd:
        fig.savefig(fd, format='svg')
        buf = fd.getvalue().decode('ascii')

    won_id = 'Computer_Modern_Sans_Serif-142'
    assert re.search(r'<path d=(.|\s)*?id="{0}"/>'.format(won_id), buf)
    assert re.search(r'<use[^/>]*? xlink:href="#{0}"/>'.format(won_id), buf)
开发者ID:dstansby,项目名称:matplotlib,代码行数:13,代码来源:test_backend_svg.py

示例4: eq

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import text [as 别名]
def eq(code, **kwargs):
	from matplotlib.figure import Figure
	import matplotlib.pyplot as plt
	plt.rc('text', usetex=True)
	plt.rc('font', family='serif')
	if "horizontalalignment" not in kwargs:
		kwargs["horizontalalignment"] = "center"
	if "verticalalignment" not in kwargs:
		kwargs["verticalalignment"] = "center"
	f = Figure(frameon=False)
	f.text(0.5, 0.5, code, **kwargs)
	return f
开发者ID:01-,项目名称:pyspread,代码行数:14,代码来源:macro_equation.py

示例5: buildMetadataImage

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import text [as 别名]
    def buildMetadataImage(self, layerInfoList, width):
        """
        Creates the metadata caption for figures in styles that display a title only.
        """
        # Find first non-outline layer.
        nonOutlineLayers = [l for l in layerInfoList if l.id != outline_layer.OUTLINE_LAYER_ID]
        layerInfo = nonOutlineLayers[0] if len(nonOutlineLayers) > 0 else None

        # Get the title of the first set of keyword data, i.e., that for the layer rather than one
        # of its antecedent layers or datasets.
        titleText = ''
        if layerInfo and (len(layerInfo.keywordData) > 0):
            titleText = layerInfo.keywordData[0].get('title', '')

        height = 500
        dpi = 100
        transparent = False

        figsize = (width / float(dpi), height / float(dpi))
        fig = Figure(figsize=figsize, dpi=dpi, facecolor='w', frameon=(not transparent))
        renderer = Renderer(fig.dpi)

        text = fig.text(0.5, 0.98, titleText,
                        fontdict=titleFont,
                        horizontalalignment='center',
                        verticalalignment='top')

        # Trim the height of the text image.
        extent = text.get_window_extent(renderer)
        textHeight = (extent.y1 - extent.y0 + 8)
        fig.set_figheight(textHeight / float(dpi))
        
        return image_util.figureToImage(fig)
开发者ID:NERC-CEH,项目名称:jules-jasmin,代码行数:35,代码来源:ipccDdcMetadataImageBuilder.py

示例6: GraficaPanel

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import text [as 别名]
class GraficaPanel(wx.Panel):
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)

        self.parent = parent
        self.ig = datetime.datetime.now()
        self.marcador = False
        self.figure = Figure(facecolor='darkslategray')
        self.axes = self.figure.add_subplot(111)
        self.axes.get_yaxis().set_visible(False)
        self.figure.text(0.5, 0.02, 'tiempo', ha='center', va='center')
        self.axes.grid()
        self.canvas = FigureCanvas(self, 0, self.figure)
        self.figure.tight_layout()
        self.dinamicas = None
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(self.canvas, 0, wx.EXPAND | wx.ALL)
        self.SetSizer(mainSizer)

    def graficado(self, s, inicio_grabacion):
        print 'dentro graficado'
        self.ig = inicio_grabacion

        def timeTicks(x, pos):
            d = (self.ig + datetime.timedelta(seconds=x)).time()
            return str(d)

        segmento = s.readframes(s.getnframes())
        duracion_archivo = int(np.round(s.getnframes() / float(s.getframerate())))

        data = np.fromstring(segmento, np.int16)
        samples = data[0::32768]
        ejetiempo = np.linspace(0, duracion_archivo, num=len(samples))

        self.axes.set_xlim([0, duracion_archivo])

        formatter = ticker.FuncFormatter(timeTicks)
        self.axes.xaxis.set_major_formatter(formatter)
        self.axes.plot(ejetiempo, samples)
        self.canvas.draw()
        self.dinamicas = GraficaDinamica(self, fig=self.canvas.figure)
        self.dinamicas.show()

    def marcable(self):
        self.marcador = True
开发者ID:Edasn,项目名称:CaptorRadio-v2,代码行数:48,代码来源:interfaz6.py

示例7: UIInt

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import text [as 别名]
class UIInt(wx.Frame):
	def __init__(self,parent):
		wx.Frame.__init__(self,parent,title=PICHI_STR,size=(400,300))
		self.funpanel = wx.Panel(self, -1)

		self.initSizers()
		self.initCanvas()
		self.initCtrls()
		
		self.SetBackgroundColour("#FFFFFF")
		
		self.Centre(1)
		self.Show()
	
	def initSizers(self):
		self.mainsz = wx.BoxSizer(wx.VERTICAL)
		self.funsz = wx.BoxSizer(wx.HORIZONTAL)
		
		self.funpanel.SetSizer(self.funsz)
		self.SetSizer(self.mainsz)
		
	def initCtrls(self):
		self.funlabel = wx.StaticText(self.funpanel, -1, " f(x) ")
		self.fun = wx.TextCtrl(self.funpanel, -1, "")
		self.boton = wx.Button(self, -1, "Integrar", size=(100,25))
		
		# Fonts
		font1 = self.funlabel.GetFont()
		font1.SetPointSize(12)
		self.funlabel.SetFont(font1)
		self.fun.SetFont(font1)
		self.fun.SetForegroundColour((0,0,255))
		
		self.funsz.Add(self.funlabel, 1, wx.EXPAND|wx.ALL, 5)
		self.funsz.Add(self.fun, 7, wx.EXPAND|wx.ALL, 5)
		self.mainsz.Add(self.funpanel, 1, wx.EXPAND|wx.ALL, 5)
		self.mainsz.Add(self.canvas, 6, wx.EXPAND|wx.ALL, 5)
		self.mainsz.Add(self.boton, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
		
		self.Bind(wx.EVT_BUTTON, self.integrar, self.boton)
		
	def initCanvas(self):
		self.figure = Figure()
		
		# FigureCanvas
		self.canvas = FigureCanvas(self, -1, self.figure)
		self.figure.set_facecolor((1,1,1))
		self.string = self.figure.text(0.05, 0.5, "")
		self.string.set_fontsize(18)
		
	def integrar(self,event):
		x = sympy.Symbol("x")
		fx = self.fun.GetValue() # Función original
		fx = preproc(fx)
		Fx = sympy.integrate(eval(fx)) # Función integrada
		str_Fx = "$\int \, (%s) \,dx \,= \,%s + C$"%(sympy.latex(eval(fx)), sympy.latex(Fx))
		self.string.set_text(str_Fx)
		self.canvas.draw()
开发者ID:JorgeDeLosSantos,项目名称:PiChi,代码行数:60,代码来源:uicalc.py

示例8: render_to_response

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import text [as 别名]
    def render_to_response(self, context):
        """Create a png image and write the control chart image to it"""

        fig = Figure(dpi=72, facecolor="white")
        dpi = fig.get_dpi()
        fig.set_size_inches(
            self.get_number_from_request("width", 700) / dpi,
            self.get_number_from_request("height", 480) / dpi,
        )
        canvas = FigureCanvas(fig)
        dates, data = [], []

        if context["data"] and context["data"].values():
            name, points = context["data"].items()[0]
            dates, data = zip(*[(ti["date"], ti["value"]) for ti in points])

        n_baseline_subgroups = self.get_number_from_request("n_baseline_subgroups", 2, dtype=int)
        n_baseline_subgroups = max(2, n_baseline_subgroups)

        subgroup_size = self.get_number_from_request("subgroup_size", 2, dtype=int)
        if not (1 < subgroup_size < 100):
            subgroup_size = 1

        include_fit = self.request.GET.get("fit_data", "") == "true"

        response = HttpResponse(mimetype="image/png")
        if n_baseline_subgroups < 1 or n_baseline_subgroups > len(data) / subgroup_size:
            fig.text(0.1, 0.9, "Not enough data for control chart", fontsize=20)
            canvas.print_png(response)
        else:
            try:
                control_chart.display(fig, numpy.array(data), subgroup_size, n_baseline_subgroups, fit=include_fit, dates=dates)
                fig.autofmt_xdate()
                canvas.print_png(response)
            except (RuntimeError, OverflowError) as e:  # pragma: nocover
                fig.clf()
                msg = "There was a problem generating your control chart:\n%s" % str(e)
                fig.text(0.1, 0.9, "\n".join(textwrap.wrap(msg, 40)), fontsize=12)
                canvas.print_png(response)

        return response
开发者ID:jrkerns,项目名称:qatrackplus,代码行数:43,代码来源:charts.py

示例9: fig_plot

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import text [as 别名]
def fig_plot(frame, tarr, parr, nshot, y_ticks=[], col='#c00000', ylbl=''):


    fig = Figure(figsize=(8.2, 8.2), dpi=100)
    can = FigureCanvasTkAgg(fig, master=frame)
    can._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
    fig.subplots_adjust(left=0.1, bottom=0.1, right=0.95, top=0.92, hspace=0)
    fig.text(.5, .95, '#%d' %nshot, ha='center')

    nsrc = parr.shape[1]
    for jx in range(nsrc):
        ax = fig.add_subplot(8, 1, jx+1)
        ax.plot(tarr, parr[:, jx], color=col)
        ax.set_ylabel('%s%d' %(ylbl, jx+1), fontsize=fsize)
        ax.set_yticks(y_ticks)
        ax.ticklabel_format(axis='y', style='sci', scilimits=(-4,-4))
        ax.yaxis.major.formatter._useMathText = True
        if jx < nsrc-1:
            ax.tick_params(axis='x', which='both', bottom='on', top='on', labelbottom='off')

    ax.set_xlabel('Time [s]', fontsize=fsize)
    can.mpl_connect('button_press_event', fconf.on_click)
    toolbar = NavigationToolbar2TkAgg(can, frame)
    toolbar.update()
开发者ID:pyIPP,项目名称:trgui,代码行数:26,代码来源:read_sig.py

示例10: buildDetailsImage

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import text [as 别名]
    def buildDetailsImage(self, layerInfoList, width):
        """
        Creates the metadata details for figures using templates.
        """
        # Find first non-outline layer.
        nonOutlineLayers = [l for l in layerInfoList if l.id != outline_layer.OUTLINE_LAYER_ID]
        layerInfo = nonOutlineLayers[0] if len(nonOutlineLayers) > 0 else None

        # Flatten the keyword dictionaries, giving priority to entries from descendants over
        # antecedents.
        keywordData = {}
        if layerInfo:
            for kw in reversed(layerInfo.keywordData):
                keywordData.update(kw)

        detailsText = caption_manager.getCaption(layerInfo, keywordData)

        height = 500
        dpi = 100
        transparent = False

        figsize = (width / float(dpi), height / float(dpi))
        fig = Figure(figsize=figsize, dpi=dpi, facecolor='w', frameon=(not transparent))
        renderer = Renderer(fig.dpi)

        text = fig.text(0.02, 0.98, detailsText,
                        fontdict=metadataFont,
                        horizontalalignment='left',
                        verticalalignment='top')

        # Trim the height of the text image.
        extent = text.get_window_extent(renderer)
        textHeight = (extent.y1 - extent.y0 + 8)
        fig.set_figheight(textHeight / float(dpi))
        
        return image_util.figureToImage(fig)
开发者ID:NERC-CEH,项目名称:jules-jasmin,代码行数:38,代码来源:ipccDdcMetadataImageBuilder.py

示例11: plotResults

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import text [as 别名]
def plotResults(request, image_id):
    import os
    import tempfile
    os.environ['MPLCONFIGDIR'] = tempfile.mkdtemp()
    from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
    from matplotlib.figure import Figure
    import numpy as np
    fig = Figure()
    ax=fig.add_subplot(3,1,1)
    if Original_nrrd.objects.filter(image=image_id).count() > 0:
      records = Original_nrrd.objects.filter(image=image_id).values()
      chanCol = ['red','green','blue']
      for record in records:
        i = int(record['channel'])
        ax=fig.add_subplot(3,1,i)
        hist = list(record['pre_hist'])
        k = range(0,len(hist))
        v = [long(y) for y in hist]
        m = int(record['new_min'])
        M = int(record['new_max'])
        ax.fill([m,M,M,m], [np.min(v),np.min(v),np.max(v),np.max(v)], 'cyan', fill=True, hatch='/', edgecolor="grey")
        # ax.broken_barh([(m, (M-m))] , (ax.yaxis, (np.max(v)-np.min(v))), facecolors='grey')
        ax.bar(k, v, color=chanCol[i-1])#, log=True

        ax.set_xlim(0,260)
        ax.set_ylim(0,np.max(v))
        ax.set_yscale('symlog', linthreshx=np.average(v))
        ax.grid(True)
        gc.collect()
        ax.set_title('Ch' + str(i) + ' histogram', fontsize=14, color=chanCol[i-1])
    else:
      fig.text(0.3,0.5,'No Data Found!', fontsize=32)
    fig.text(0.5, 0.015, 'Intensity', ha='center', va='center')
    fig.text(0.015, 0.5, 'Count (log)', ha='center', va='center', rotation='vertical')
    fig.tight_layout()
    canvas = FigureCanvas(fig)
    response = HttpResponse(content_type='image/png')
    gc.collect()
    canvas.print_png(response)
    return response
开发者ID:Robbie1977,项目名称:AlignmentPipe,代码行数:42,代码来源:views.py

示例12: SpatialDecisionDockWidget

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import text [as 别名]
class SpatialDecisionDockWidget(QtGui.QDockWidget, FORM_CLASS):
    closingPlugin = QtCore.pyqtSignal()
    # custom signals
    updateAttribute = QtCore.pyqtSignal(str)

    def __init__(self, iface, parent=None):
        """Constructor."""
        super(SpatialDecisionDockWidget, self).__init__(parent)
        # Set up the user interface from Designer.
        # After setupUI you can access any designer object by doing
        # self.<objectname>, and you can use autoconnect slots - see
        # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
        # #widgets-and-dialogs-with-auto-connect
        self.setupUi(self)

        # define globals
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
        self.canvas.setSelectionColor(QtGui.QColor(255, 0, 0))

        # set up GUI operation signals
        # data
        self.iface.projectRead.connect(self.updateLayers)
        self.iface.newProjectCreated.connect(self.updateLayers)
        self.selectLayerCombo.activated.connect(self.setSelectedLayer)
        self.selectAttributeCombo.activated.connect(self.setSelectedAttribute)
        self.showButton.clicked.connect(self.updateValueWidget)

        # signals
        self.canvas.renderStarting.connect(self.loadSymbols)
        self.canvas.selectionChanged.connect(self.updateValueWidget)

        # analysis
        self.graph = QgsGraph()
        self.tied_points = []
        self.shortestRouteButton.clicked.connect(self.calculateRoute)
        self.clearRouteButton.clicked.connect(self.deleteRoutes)
        self.assignButton.clicked.connect(self.assignFacility)
        self.clearAssignmentButton.clicked.connect(self.clearAssignment)
        self.changeStatusButton.clicked.connect(self.changeEventStatus)

        # visualisation

        # set current UI restrictions
        # initialisation
        self.eventlayer = uf.getLegendLayerByName(self.iface, 'Reports')
        self.hospitalLayer = uf.getLegendLayerByName(self.iface, 'Hospital')
        self.firestationLayer = uf.getLegendLayerByName(self.iface, 'Firestation')
        self.hospital_name=''
        self.firestation_name=''
        self.event_source=self.eventlayer.selectedFeatures()

        # example_chart
        # add matplotlib Figure to chartFrame
        self.chart_figure = Figure()
        self.chart_subplot_radar = self.chart_figure.add_subplot(211, projection='polar')
        self.chart_subplot_bar = self.chart_figure.add_subplot(212)
        self.chart_figure.tight_layout()
        self.chart_figure.text(0.05, 0.955, 'Data from:', fontsize = 12, horizontalalignment = 'left')
        self.chart_figure.text(0.05, 0.93, self.getWindDate(), fontsize = 12, fontweight='bold', horizontalalignment = 'left')
        self.chart_canvas = FigureCanvas(self.chart_figure)
        self.chartLayout.addWidget(self.chart_canvas)

        self.updateLayers()

        # run simple tests

    def closeEvent(self, event):
        # disconnect interface signals
        self.iface.projectRead.disconnect(self.updateLayers)
        self.iface.newProjectCreated.disconnect(self.updateLayers)

        self.closingPlugin.emit()
        event.accept()

    #######
    #   Data functions
    #######

    def updateLayers(self):
        layers = uf.getLegendLayers(self.iface, 'all', 'all')
        self.selectLayerCombo.clear()
        if layers:
            layer_names = uf.getLayersListNames(layers)
            self.selectLayerCombo.addItems(layer_names)
            self.setSelectedLayer()
            self.plotChart()
        #else:
        #    self.clearChart()  # example_chart

    def setSelectedLayer(self):
        layer_name = self.selectLayerCombo.currentText()
        layer = uf.getLegendLayerByName(self.iface, layer_name)
        self.updateAttributes(layer)

    def getSelectedLayer(self):
        layer_name = self.selectLayerCombo.currentText()
        layer = uf.getLegendLayerByName(self.iface, layer_name)
        return layer

#.........这里部分代码省略.........
开发者ID:balazsdukai,项目名称:GEO1005-StormManager,代码行数:103,代码来源:spatial_decision_dockwidget.py

示例13: __init__

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import text [as 别名]
class FigureTab:
  cursors = [15000, 45000]
  colors = ['orange', 'violet']

  def __init__(self, layout, vna):
    # create figure
    self.figure = Figure()
    if sys.platform != 'win32':
      self.figure.set_facecolor('none')
    self.canvas = FigureCanvas(self.figure)
    layout.addWidget(self.canvas)
    # create navigation toolbar
    self.toolbar = NavigationToolbar(self.canvas, None, False)
    self.toolbar.layout().setSpacing(6)
    # remove subplots action
    actions = self.toolbar.actions()
    if int(matplotlib.__version__[0]) < 2:
      self.toolbar.removeAction(actions[7])
    else:
      self.toolbar.removeAction(actions[6])
    self.toolbar.addSeparator()
    self.cursorLabels = {}
    self.cursorValues = {}
    self.cursorMarkers = {}
    self.cursorPressed = {}
    for i in range(len(self.cursors)):
      self.cursorMarkers[i] = None
      self.cursorPressed[i] = False
      self.cursorLabels[i] = QLabel('Cursor %d, kHz' % (i + 1))
      self.cursorLabels[i].setStyleSheet('color: %s' % self.colors[i])
      self.cursorValues[i] = QSpinBox()
      self.cursorValues[i].setMinimumSize(90, 0)
      self.cursorValues[i].setSingleStep(10)
      self.cursorValues[i].setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter)
      self.toolbar.addWidget(self.cursorLabels[i])
      self.toolbar.addWidget(self.cursorValues[i])
      self.cursorValues[i].valueChanged.connect(partial(self.set_cursor, i))
      self.canvas.mpl_connect('button_press_event', partial(self.press_marker, i))
      self.canvas.mpl_connect('motion_notify_event', partial(self.move_marker, i))
      self.canvas.mpl_connect('button_release_event', partial(self.release_marker, i))
    self.toolbar.addSeparator()
    self.plotButton = QPushButton('Rescale')
    self.toolbar.addWidget(self.plotButton)
    layout.addWidget(self.toolbar)
    self.plotButton.clicked.connect(self.plot)
    self.mode = None
    self.vna = vna

  def add_cursors(self, axes):
    if self.mode == 'gain_short' or self.mode == 'gain_open':
      columns = ['Freq., kHz', 'G, dB', r'$\angle$ G, deg']
    else:
      columns = ['Freq., kHz', 'Re(Z), \u03A9', 'Im(Z), \u03A9', '|Z|, \u03A9', r'$\angle$ Z, deg', 'SWR', r'|$\Gamma$|', r'$\angle$ $\Gamma$, deg', 'RL, dB']
    y = len(self.cursors) * 0.04 + 0.01
    for i in range(len(columns)):
      self.figure.text(0.19 + 0.1 * i, y, columns[i], horizontalalignment = 'right')
    self.cursorRows = {}
    for i in range(len(self.cursors)):
      y = len(self.cursors) * 0.04 - 0.03 - 0.04 * i
      self.figure.text(0.01, y, 'Cursor %d' % (i + 1), color = self.colors[i])
      self.cursorRows[i] = {}
      for j in range(len(columns)):
        self.cursorRows[i][j] = self.figure.text(0.19 + 0.1 * j, y, '', horizontalalignment = 'right')
      if self.mode == 'smith':
        self.cursorMarkers[i], = axes.plot(0.0, 0.0, marker = 'o', color = self.colors[i])
      else:
        self.cursorMarkers[i] = axes.axvline(0.0, color = self.colors[i], linewidth = 2)
      self.set_cursor(i, self.cursorValues[i].value())

  def set_cursor(self, index, value):
    FigureTab.cursors[index] = value
    marker = self.cursorMarkers[index]
    if marker is None: return
    row = self.cursorRows[index]
    freq = value
    gamma = self.vna.gamma(freq)
    if self.mode == 'smith':
      marker.set_xdata(gamma.real)
      marker.set_ydata(gamma.imag)
    else:
      marker.set_xdata(freq)
    row[0].set_text('%d' % freq)
    if self.mode == 'gain_short':
      gain = self.vna.gain_short(freq)
      magnitude = 20.0 * np.log10(np.absolute(gain))
      angle = np.angle(gain, deg = True)
      row[1].set_text(unicode_minus('%.1f' % magnitude))
      row[2].set_text(unicode_minus('%.1f' % angle))
    elif self.mode == 'gain_open':
      gain = self.vna.gain_open(freq)
      magnitude = 20.0 * np.log10(np.absolute(gain))
      angle = np.angle(gain, deg = True)
      row[1].set_text(unicode_minus('%.1f' % magnitude))
      row[2].set_text(unicode_minus('%.1f' % angle))
    else:
      swr = self.vna.swr(freq)
      z = self.vna.impedance(freq)
      rl = 20.0 * np.log10(np.absolute(gamma))
      if rl > -0.01: rl = 0.0
      row[1].set_text(metric_prefix(z.real))
#.........这里部分代码省略.........
开发者ID:pavel-demin,项目名称:red-pitaya-notes,代码行数:103,代码来源:vna.py

示例14: MediaPanel

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import text [as 别名]
class MediaPanel(wx.Panel):
    """" clase llamada por MediaFrame (padre)"""

    #----------------------------------------------------------------------
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)

        #Para el menu de archivos y el modelo a usar por defecto
        sp = wx.StandardPaths.Get()
        self.currentFolder = sp.GetDocumentsDir()
        self.currentFile = ''
        self.s=''
        #modelo de reconocimiento
        self.currentModel = 'C:\Users\Mario\Desktop\hito1\modelos\ExtraTreesClassifier_Apr0816\ExtraTreesClassifier_Apr0816.pkl'

        #cantidad de segundos de inicio
        self.ventana=180

        #control de offset para la grafica
        self.t=0
        self.bloqueo=False
        #contador de tiempo inicial
        self.marcador='00:00:00'
        self.inicio_grabacion = datetime.datetime(2000, 1, 1, 0, 0)
        #parent y creacion de menu y apariencia

        self.frame = parent
        self.SetBackgroundColour("white")
        self.currentVolume = 50
        self.createMenu()
        self.layoutControls()

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

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onTimer)
        self.timer.Start(100)


    #----------------------------------------------------------------------
    def layoutControls(self):
        """
        Creacion de dispositivos de la aplicacion
        """

        try:
            self.mediaPlayer = wx.media.MediaCtrl(self, style=wx.RAISED_BORDER)
        except NotImplementedError:
            self.Destroy()
            raise

        #self.Bind(wx.EVT_PAINT, self.OnDibujo)

        # barra de reproduccion     ################
        sliderSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.playbackSlider = wx.Slider(self, size=wx.DefaultSize)
        self.Bind(wx.EVT_SLIDER, self.onSeek, self.playbackSlider)
        sliderSizer.Add(self.playbackSlider, 3, wx.ALL|wx.EXPAND, 5)

        #CANVAS (figura) y barra de herramientas #####################

        self.figure = Figure(facecolor='white')
        self.axes = self.figure.add_subplot(111)

        self.axes.get_yaxis().set_visible(False)
        self.figure.text(0.5, 0.04, 'tiempo', ha='center', va='center')
        self.axes.grid()
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.chart_toolbar = MyCustomToolbar(self.canvas)
        self.chart_toolbar.Realize()



        ###### SIZERS ###################################
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.barra_1h_hora_sizer = wx.BoxSizer(wx.VERTICAL)
        self.barra_1h_hora_sizer1 = wx.BoxSizer(wx.HORIZONTAL)
        self.barra_1h_hora_sizer2 = wx.BoxSizer(wx.HORIZONTAL)
        self.barra_1h_hora_sizer.Add(self.barra_1h_hora_sizer1, 0, wx.EXPAND)
        self.barra_1h_hora_sizer.Add(self.barra_1h_hora_sizer2, 0, wx.EXPAND)
        self.audioSizer = self.buildAudioBar()

        #self.anuncios = wx.StaticText(self,1,"Anuncios",(200, 300) )

        #widgets--COLOCACION DE BARRA DE REPRODUCCION, CONTROLADORES Y GRAFICA
        mainSizer.Add(self.barra_1h_hora_sizer, 0, wx.RIGHT | wx.LEFT | wx.TOP | wx.EXPAND, 50)
        mainSizer.Add(sliderSizer, 0, wx.ALL|wx.EXPAND, 50)
        mainSizer.Add(self.audioSizer, 0, wx.CENTER, 1)
        mainSizer.Add(self.canvas, 1, wx.CENTER|wx.EXPAND, 0)
        mainSizer.Add(self.chart_toolbar, 1, flag=wx.ALIGN_CENTER, border=2)
        #mainSizer.Add(self.anuncios, 1, wx.EXPAND, 0)


        self.SetSizerAndFit(mainSizer)

        self.Layout()

    def resultProducer(self, audio,):
        """Pretend to be a complex worker function or something that takes
#.........这里部分代码省略.........
开发者ID:Edasn,项目名称:CaptorRadio-v2,代码行数:103,代码来源:interfaz2.py

示例15: MediaPanel

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import text [as 别名]
class MediaPanel(wx.Panel):
    """" clase llamada por MediaFrame (padre)"""

    #----------------------------------------------------------------------
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)

        #parent y creacion de menu y apariencia

        self.frame = parent
        self.SetBackgroundColour("white")
        self.currentVolume = 50
        self.createMenu()
        self.layoutControls()

        #Adjuntamos barra indicadora lo hacemos sensible a tamanho (?)
        #todo hay que poner eventos OnClick y eje de tiempos

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


        #Para el menu de archivos y el modelo a usar por defecto
        sp = wx.StandardPaths.Get()
        self.currentFolder = sp.GetDocumentsDir()
        self.currentFile = ''
        #modelo de reconocimiento
        self.currentModel = 'D:\\archivos_captor\modelos\ExtraTreesClassifier_Apr0816.pkl'

        #cantidad de segundos de inicio
        self.ventana=60

        #control de offset para la grafica
        self.t=0


        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onTimer)
        self.timer.Start(100)


    #----------------------------------------------------------------------
    def layoutControls(self):
        """
        Creacion de dispositivos de la aplicacion
        """


        try:
            self.mediaPlayer = wx.media.MediaCtrl(self, style=wx.RAISED_BORDER)
        except NotImplementedError:
            self.Destroy()
            raise


        self.Bind(wx.EVT_PAINT, self.OnDibujo)

        # barra de reproduccion     ################
        sliderSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.playbackSlider = wx.Slider(self, size=wx.DefaultSize)
        self.Bind(wx.EVT_SLIDER, self.onSeek, self.playbackSlider)
        sliderSizer.Add(self.playbackSlider, 3, wx.ALL|wx.EXPAND, 5)


        #CANVAS (figura) y barra de herramientas #####################
        self.figure = Figure(facecolor='white')
        self.axes = self.figure.add_subplot(111)
        self.axes.get_yaxis().set_visible(False)
        self.figure.text(0.5, 0.04, 'segundos', ha='center', va='center')
        self.axes.grid()
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.chart_toolbar = MyCustomToolbar(self.canvas)
        self.chart_toolbar.Realize()


        ###### SIZERS ###################################
        mainSizer = wx.BoxSizer(wx.VERTICAL)

        audioSizer = self.buildAudioBar()



        #widgets--COLOCACION DE BARRA DE REPRODUCCION, CONTROLADORES Y GRAFICA
        mainSizer.Add(self.playbackSlider, 0, wx.ALL|wx.EXPAND, 50)
        mainSizer.Add(audioSizer, 0, wx.LEFT|wx.CENTER, 50)
        mainSizer.Add(self.canvas, 0, wx.LEFT|wx.EXPAND, 50)
        mainSizer.Add(self.chart_toolbar, 1, flag=wx.ALIGN_CENTER, border=2)

        self.SetSizer(mainSizer)

        self.Layout()


    #----------------------------------------------------------------------
    def buildAudioBar(self):
        """
        Construye los controladores de audio
        """
        audioBarSizer = wx.BoxSizer(wx.HORIZONTAL)

#.........这里部分代码省略.........
开发者ID:Edasn,项目名称:CaptorRadio-v2,代码行数:103,代码来源:interfaz.py


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