本文整理汇总了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')
示例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
示例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
示例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
示例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
示例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 = []
示例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)
示例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
示例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')
示例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()
示例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')
示例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
示例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()
示例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)
示例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