當前位置: 首頁>>代碼示例>>Python>>正文


Python mathtext.MathTextParser方法代碼示例

本文整理匯總了Python中matplotlib.mathtext.MathTextParser方法的典型用法代碼示例。如果您正苦於以下問題:Python mathtext.MathTextParser方法的具體用法?Python mathtext.MathTextParser怎麽用?Python mathtext.MathTextParser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.mathtext的用法示例。


在下文中一共展示了mathtext.MathTextParser方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from matplotlib import mathtext [as 別名]
# 或者: from matplotlib.mathtext import MathTextParser [as 別名]
def __init__(self, width, height, dpi):
        if __debug__: verbose.report('RendererAgg.__init__', 'debug-annoying')
        RendererBase.__init__(self)
        self.texd = maxdict(50)  # a cache of tex image rasters

        self.dpi = dpi
        self.width = width
        self.height = height
        if __debug__: verbose.report('RendererAgg.__init__ width=%s, height=%s'%(width, height), 'debug-annoying')
        self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False)
        self._filter_renderers = []

        if __debug__: verbose.report('RendererAgg.__init__ _RendererAgg done',
                                     'debug-annoying')

        self._update_methods()
        self.mathtext_parser = MathTextParser('Agg')

        self.bbox = Bbox.from_bounds(0, 0, self.width, self.height)
        if __debug__: verbose.report('RendererAgg.__init__ done',
                                     'debug-annoying') 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:23,代碼來源:backend_agg.py

示例2: get_label_width

# 需要導入模塊: from matplotlib import mathtext [as 別名]
# 或者: from matplotlib.mathtext import MathTextParser [as 別名]
def get_label_width(self, lev, fmt, fsize):
        """
        Return the width of the label in points.
        """
        if not cbook.is_string_like(lev):
            lev = self.get_text(lev, fmt)

        lev, ismath = text.Text.is_math_text(lev)
        if ismath == 'TeX':
            if not hasattr(self, '_TeX_manager'):
                self._TeX_manager = texmanager.TexManager()
            lw, _, _ = self._TeX_manager.get_text_width_height_descent(lev,
                                                                       fsize)
        elif ismath:
            if not hasattr(self, '_mathtext_parser'):
                self._mathtext_parser = mathtext.MathTextParser('bitmap')
            img, _ = self._mathtext_parser.parse(lev, dpi=72,
                                                 prop=self.labelFontProps)
            lw = img.get_width()  # at dpi=72, the units are PostScript points
        else:
            # width is much less than "font size"
            lw = (len(lev)) * fsize * 0.6

        return lw 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:26,代碼來源:contour.py

示例3: get_label_width

# 需要導入模塊: from matplotlib import mathtext [as 別名]
# 或者: from matplotlib.mathtext import MathTextParser [as 別名]
def get_label_width(self, lev, fmt, fsize):
        """
        Return the width of the label in points.
        """
        if not isinstance(lev, str):
            lev = self.get_text(lev, fmt)

        lev, ismath = text.Text.is_math_text(lev)
        if ismath == 'TeX':
            if not hasattr(self, '_TeX_manager'):
                self._TeX_manager = texmanager.TexManager()
            lw, _, _ = self._TeX_manager.get_text_width_height_descent(lev,
                                                                       fsize)
        elif ismath:
            if not hasattr(self, '_mathtext_parser'):
                self._mathtext_parser = mathtext.MathTextParser('bitmap')
            img, _ = self._mathtext_parser.parse(lev, dpi=72,
                                                 prop=self.labelFontProps)
            lw = img.get_width()  # at dpi=72, the units are PostScript points
        else:
            # width is much less than "font size"
            lw = (len(lev)) * fsize * 0.6

        return lw 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:26,代碼來源:contour.py

示例4: get_label_width

# 需要導入模塊: from matplotlib import mathtext [as 別名]
# 或者: from matplotlib.mathtext import MathTextParser [as 別名]
def get_label_width(self, lev, fmt, fsize):
        """
        Return the width of the label in points.
        """
        if not isinstance(lev, str):
            lev = self.get_text(lev, fmt)

        lev, ismath = text.Text()._preprocess_math(lev)
        if ismath == 'TeX':
            if not hasattr(self, '_TeX_manager'):
                self._TeX_manager = texmanager.TexManager()
            lw, _, _ = self._TeX_manager.get_text_width_height_descent(lev,
                                                                       fsize)
        elif ismath:
            if not hasattr(self, '_mathtext_parser'):
                self._mathtext_parser = mathtext.MathTextParser('bitmap')
            img, _ = self._mathtext_parser.parse(lev, dpi=72,
                                                 prop=self.labelFontProps)
            lw = img.get_width()  # at dpi=72, the units are PostScript points
        else:
            # width is much less than "font size"
            lw = (len(lev)) * fsize * 0.6

        return lw 
開發者ID:boris-kz,項目名稱:CogAlg,代碼行數:26,代碼來源:contour.py

示例5: get_label_width

# 需要導入模塊: from matplotlib import mathtext [as 別名]
# 或者: from matplotlib.mathtext import MathTextParser [as 別名]
def get_label_width(self, lev, fmt, fsize):
        """
        Return the width of the label in points.
        """
        if not isinstance(lev, six.string_types):
            lev = self.get_text(lev, fmt)

        lev, ismath = text.Text.is_math_text(lev)
        if ismath == 'TeX':
            if not hasattr(self, '_TeX_manager'):
                self._TeX_manager = texmanager.TexManager()
            lw, _, _ = self._TeX_manager.get_text_width_height_descent(lev,
                                                                       fsize)
        elif ismath:
            if not hasattr(self, '_mathtext_parser'):
                self._mathtext_parser = mathtext.MathTextParser('bitmap')
            img, _ = self._mathtext_parser.parse(lev, dpi=72,
                                                 prop=self.labelFontProps)
            lw = img.get_width()  # at dpi=72, the units are PostScript points
        else:
            # width is much less than "font size"
            lw = (len(lev)) * fsize * 0.6

        return lw 
開發者ID:alvarobartt,項目名稱:twitter-stock-recommendation,代碼行數:26,代碼來源:contour.py

示例6: __init__

# 需要導入模塊: from matplotlib import mathtext [as 別名]
# 或者: from matplotlib.mathtext import MathTextParser [as 別名]
def __init__(self, widget):
        super(RendererKivy, self).__init__()
        self.widget = widget
        self.dpi = widget.figure.dpi
        self._markers = {}
        #  Can be enhanced by using TextToPath matplotlib, textpath.py
        self.mathtext_parser = MathTextParser("Bitmap")
        self.list_goraud_triangles = []
        self.clip_rectangles = []
        self.labels_inside_plot = [] 
開發者ID:kivy-garden,項目名稱:garden.matplotlib,代碼行數:12,代碼來源:backend_kivy.py

示例7: __init__

# 需要導入模塊: from matplotlib import mathtext [as 別名]
# 或者: from matplotlib.mathtext import MathTextParser [as 別名]
def __init__(self, dpi):
        """
        """
        if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))
        self.dpi = dpi
        self.gc = GraphicsContextCairo (renderer=self)
        self.text_ctx = cairo.Context (
           cairo.ImageSurface (cairo.FORMAT_ARGB32,1,1))
        self.mathtext_parser = MathTextParser('Cairo')

        RendererBase.__init__(self) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:13,代碼來源:backend_cairo.py

示例8: __init__

# 需要導入模塊: from matplotlib import mathtext [as 別名]
# 或者: from matplotlib.mathtext import MathTextParser [as 別名]
def __init__(self, file, image_dpi):
        RendererBase.__init__(self)
        self.file = file
        self.gc = self.new_gc()
        self.mathtext_parser = MathTextParser("Pdf")
        self.image_dpi = image_dpi
        self.tex_font_map = None 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:9,代碼來源:backend_pdf.py

示例9: __init__

# 需要導入模塊: from matplotlib import mathtext [as 別名]
# 或者: from matplotlib.mathtext import MathTextParser [as 別名]
def __init__(self, width, height, pswriter, imagedpi=72):
        """
        Although postscript itself is dpi independent, we need to
        imform the image code about a requested dpi to generate high
        res images and them scale them before embeddin them
        """
        RendererBase.__init__(self)
        self.width = width
        self.height = height
        self._pswriter = pswriter
        if rcParams['text.usetex']:
            self.textcnt = 0
            self.psfrag = []
        self.imagedpi = imagedpi

        # current renderer state (None=uninitialised)
        self.color = None
        self.linewidth = None
        self.linejoin = None
        self.linecap = None
        self.linedash = None
        self.fontname = None
        self.fontsize = None
        self._hatches = {}
        self.image_magnification = imagedpi/72.0
        self._clip_paths = {}
        self._path_collection_id = 0

        self.used_characters = {}
        self.mathtext_parser = MathTextParser("PS")

        self._afm_font_dir = os.path.join(
            rcParams['datapath'], 'fonts', 'afm') 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:35,代碼來源:backend_ps.py

示例10: __init__

# 需要導入模塊: from matplotlib import mathtext [as 別名]
# 或者: from matplotlib.mathtext import MathTextParser [as 別名]
def __init__(self, width, height, svgwriter, basename=None, image_dpi=72):
        self.width = width
        self.height = height
        self.writer = XMLWriter(svgwriter)
        self.image_dpi = image_dpi # the actual dpi we want to rasterize stuff with

        self._groupd = {}
        if not rcParams['svg.image_inline']:
            assert basename is not None
            self.basename = basename
            self._imaged = {}
        self._clipd = {}
        self._char_defs = {}
        self._markers = {}
        self._path_collection_id = 0
        self._imaged = {}
        self._hatchd = {}
        self._has_gouraud = False
        self._n_gradients = 0
        self._fonts = {}
        self.mathtext_parser = MathTextParser('SVG')

        RendererBase.__init__(self)
        self._glyph_map = dict()

        svgwriter.write(svgProlog)
        self._start_id = self.writer.start(
            u'svg',
            width=u'%ipt' % width, height='%ipt' % height,
            viewBox=u'0 0 %i %i' % (width, height),
            xmlns=u"http://www.w3.org/2000/svg",
            version=u"1.1",
            attrib={u'xmlns:xlink': u"http://www.w3.org/1999/xlink"})
        self._write_default_style() 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:36,代碼來源:backend_svg.py

示例11: __init__

# 需要導入模塊: from matplotlib import mathtext [as 別名]
# 或者: from matplotlib.mathtext import MathTextParser [as 別名]
def __init__(self, dpi, width, height):
        RendererBase.__init__(self)
        self.dpi = dpi
        self.width = width
        self.height = height
        self.gc = GraphicsContextMac()
        self.gc.set_dpi(self.dpi)
        self.mathtext_parser = MathTextParser('MacOSX') 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:10,代碼來源:backend_macosx.py

示例12: __init__

# 需要導入模塊: from matplotlib import mathtext [as 別名]
# 或者: from matplotlib.mathtext import MathTextParser [as 別名]
def __init__(self):
        """
        Initialization
        """
        self.mathtext_parser = MathTextParser('path')
        self.tex_font_map = None

        from matplotlib.cbook import maxdict
        self._ps_fontd = maxdict(50)

        self._texmanager = None

        self._adobe_standard_encoding = None 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:15,代碼來源:textpath.py

示例13: latex_to_png_mpl

# 需要導入模塊: from matplotlib import mathtext [as 別名]
# 或者: from matplotlib.mathtext import MathTextParser [as 別名]
def latex_to_png_mpl(s, wrap):
    try:
        from matplotlib import mathtext
        from matplotlib import rcParams
    except ImportError:
        return None

    if wrap:
        s = '${0}$'.format(s)
    mt = mathtext.MathTextParser('bitmap')
    f = BytesIO()
    mt.to_png(f, s, fontsize=12, dpi=rcParams['figure.dpi'])   # TODO
    return f.getvalue() 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:15,代碼來源:latextools.py

示例14: __init__

# 需要導入模塊: from matplotlib import mathtext [as 別名]
# 或者: from matplotlib.mathtext import MathTextParser [as 別名]
def __init__(self, dpi):
        self.dpi = dpi
        self.gc = GraphicsContextCairo(renderer=self)
        self.text_ctx = cairo.Context(
           cairo.ImageSurface(cairo.FORMAT_ARGB32, 1, 1))
        self.mathtext_parser = MathTextParser('Cairo')
        RendererBase.__init__(self) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:9,代碼來源:backend_cairo.py

示例15: __init__

# 需要導入模塊: from matplotlib import mathtext [as 別名]
# 或者: from matplotlib.mathtext import MathTextParser [as 別名]
def __init__(self, file, image_dpi, height, width):
        RendererBase.__init__(self)
        self.height = height
        self.width = width
        self.file = file
        self.gc = self.new_gc()
        self.mathtext_parser = MathTextParser("Pdf")
        self.image_dpi = image_dpi 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:10,代碼來源:backend_pdf.py


注:本文中的matplotlib.mathtext.MathTextParser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。