本文整理汇总了Python中matplotlib.backend_bases.RendererBase类的典型用法代码示例。如果您正苦于以下问题:Python RendererBase类的具体用法?Python RendererBase怎么用?Python RendererBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RendererBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, width, height, svgwriter, basename=None):
self.width = width
self.height = height
self.writer = XMLWriter(svgwriter)
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:xiron,项目名称:matplotlib,代码行数:35,代码来源:backend_svg.py
示例2: __init__
def __init__(self, dpi, width, height):
RendererBase.__init__(self)
self.dpi = dpi
self.width = width
self.height = height
self.gc = GraphicsContextMac()
self.mathtext_parser = MathTextParser('MacOSX')
开发者ID:astraw,项目名称:matplotlib,代码行数:7,代码来源:backend_macosx.py
示例3: __init__
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 = OrderedDict()
self._char_defs = {}
self._markers = {}
self._path_collection_id = 0
self._imaged = {}
self._hatchd = OrderedDict()
self._has_gouraud = False
self._n_gradients = 0
self._fonts = OrderedDict()
self.mathtext_parser = MathTextParser('SVG')
RendererBase.__init__(self)
self._glyph_map = dict()
svgwriter.write(svgProlog)
self._start_id = self.writer.start(
'svg',
width='%ipt' % width, height='%ipt' % height,
viewBox='0 0 %i %i' % (width, height),
xmlns="http://www.w3.org/2000/svg",
version="1.1",
attrib={'xmlns:xlink': "http://www.w3.org/1999/xlink"})
self._write_default_style()
开发者ID:4over7,项目名称:matplotlib,代码行数:34,代码来源:backend_svg.py
示例4: __init__
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._fontd = maxdict(50)
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)
if __debug__: verbose.report('RendererAgg.__init__ _RendererAgg done',
'debug-annoying')
#self.draw_path = self._renderer.draw_path # see below
self.draw_markers = self._renderer.draw_markers
self.draw_path_collection = self._renderer.draw_path_collection
self.draw_quad_mesh = self._renderer.draw_quad_mesh
self.draw_image = self._renderer.draw_image
self.copy_from_bbox = self._renderer.copy_from_bbox
self.tostring_rgba_minimized = self._renderer.tostring_rgba_minimized
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:AndreI11,项目名称:SatStressGui,代码行数:25,代码来源:backend_agg.py
示例5: __init__
def __init__(self, width, height, dpi, dxfversion):
RendererBase.__init__(self)
self.height = height
self.width = width
self.dpi = dpi
self.dxfversion = dxfversion
self._init_drawing()
开发者ID:dmkent,项目名称:mpldxf,代码行数:7,代码来源:backend_dxf.py
示例6: __init__
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:tomflannaghan,项目名称:matplotlib,代码行数:7,代码来源:backend_cairo.py
示例7: __init__
def __init__(self, width, height, ipewriter, basename):
self.width = width
self.height = height
self.writer = XMLWriter(ipewriter)
self.basename = basename
RendererBase.__init__(self)
# use same latex as Ipe (default is xelatex)
rcParams['pgf.texsystem'] = "pdflatex"
self.latexManager = None
if rcParams.get("ipe.textsize", False):
self.latexManager = LatexManagerFactory.get_latex_manager()
self._start_id = self.writer.start(
u'ipe',
version=u"70005",
creator="matplotlib")
pre = rcParams.get('ipe.preamble', "")
if pre != "":
self.writer.start(u'preamble')
self.writer.data(pre)
self.writer.end(indent=False)
sheet = rcParams.get('ipe.stylesheet', "")
if sheet != "":
self.writer.insertSheet(sheet)
self.writer.start(u'ipestyle', name=u"opacity")
for i in range(10,100,10):
self.writer.element(u'opacity', name=u'%02d%%'% i,
value=u'%g'% (i/100.0))
self.writer.end()
self.writer.start(u'page')
开发者ID:otfried,项目名称:ipe-tools,代码行数:33,代码来源:backend_ipe.py
示例8: __init__
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
if rcParams['path.simplify']:
self.simplify = (width * imagedpi, height * imagedpi)
else:
self.simplify = None
# 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")
开发者ID:zoccolan,项目名称:eyetracker,代码行数:34,代码来源:backend_ps.py
示例9: __init__
def __init__(self, figure, fh, dummy=False):
"""
Creates a new PGF renderer that translates any drawing instruction
into text commands to be interpreted in a latex pgfpicture environment.
Attributes:
* figure: Matplotlib figure to initialize height, width and dpi from.
* fh: File handle for the output of the drawing commands.
"""
RendererBase.__init__(self)
self.dpi = figure.dpi
self.fh = fh
self.figure = figure
self.image_counter = 0
# get LatexManager instance
self.latexManager = LatexManagerFactory.get_latex_manager()
if dummy:
# dummy==True deactivate all methods
nop = lambda *args, **kwargs: None
for m in RendererPgf.__dict__.keys():
if m.startswith("draw_"):
self.__dict__[m] = nop
else:
# if fh does not belong to a filename, deactivate draw_image
if not hasattr(fh, 'name') or not os.path.exists(fh.name):
warnings.warn("streamed pgf-code does not support raster "
"graphics, consider using the pgf-to-pdf option",
UserWarning)
self.__dict__["draw_image"] = lambda *args, **kwargs: None
开发者ID:717524640,项目名称:matplotlib,代码行数:31,代码来源:backend_pgf.py
示例10: __init__
def __init__(self, figure, fh, dummy=False):
"""
Creates a new PGF renderer that translates any drawing instruction
into text commands to be interpreted in a latex pgfpicture environment.
Attributes
----------
figure : `matplotlib.figure.Figure`
Matplotlib figure to initialize height, width and dpi from.
fh : file-like
File handle for the output of the drawing commands.
"""
RendererBase.__init__(self)
self.dpi = figure.dpi
self.fh = fh
self.figure = figure
self.image_counter = 0
# get LatexManager instance
self.latexManager = LatexManager._get_cached_or_new()
if dummy:
# dummy==True deactivate all methods
for m in RendererPgf.__dict__:
if m.startswith("draw_"):
self.__dict__[m] = lambda *args, **kwargs: None
else:
# if fh does not belong to a filename, deactivate draw_image
if not hasattr(fh, 'name') or not os.path.exists(fh.name):
cbook._warn_external("streamed pgf-code does not support "
"raster graphics, consider using the "
"pgf-to-pdf option", UserWarning)
self.__dict__["draw_image"] = lambda *args, **kwargs: None
开发者ID:QuLogic,项目名称:matplotlib,代码行数:34,代码来源:backend_pgf.py
示例11: __init__
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:NigelKB,项目名称:matplotlib,代码行数:11,代码来源:backend_cairo.py
示例12: restore_region
def restore_region(self, region, bbox=None, xy=None):
return RendererBase.restore_region(self, region, bbox=None, xy=None)
"""
Restore the saved region. If bbox (instance of BboxBase, or
its extents) is given, only the region specified by the bbox
will be restored. *xy* (a tuple of two floasts) optionally
specifies the new position (the LLC of the original region,
not the LLC of the bbox) where the region will be restored.
>>> region = renderer.copy_from_bbox()
>>> x1, y1, x2, y2 = region.get_extents()
>>> renderer.restore_region(region, bbox=(x1+dx, y1, x2, y2),
... xy=(x1-dx, y1))
"""
if bbox is not None or xy is not None:
if bbox is None:
x1, y1, x2, y2 = region.get_extents()
elif isinstance(bbox, BboxBase):
x1, y1, x2, y2 = bbox.extents
else:
x1, y1, x2, y2 = bbox
if xy is None:
ox, oy = x1, y1
else:
ox, oy = xy
self._renderer.restore_region2(region, x1, y1, x2, y2, ox, oy)
else:
self._renderer.restore_region(region)
开发者ID:piScope,项目名称:piScope,代码行数:32,代码来源:renderer_gl.py
示例13: check
def check(master_transform, paths, all_transforms,
offsets, facecolors, edgecolors):
rb = RendererBase()
raw_paths = list(rb._iter_collection_raw_paths(
master_transform, paths, all_transforms))
gc = rb.new_gc()
ids = [path_id for xo, yo, path_id, gc0, rgbFace in
rb._iter_collection(gc, master_transform, all_transforms,
range(len(raw_paths)), offsets,
transforms.IdentityTransform(),
facecolors, edgecolors, [], [], [False],
[], 'data')]
uses = rb._iter_collection_uses_per_path(
paths, all_transforms, offsets, facecolors, edgecolors)
if raw_paths:
seen = np.bincount(ids, minlength=len(raw_paths))
assert set(seen).issubset([uses - 1, uses])
开发者ID:vapier,项目名称:matplotlib,代码行数:17,代码来源:test_backend_bases.py
示例14: __init__
def __init__(self, figure, fh):
"""
Creates a new PGF renderer that translates any drawing instruction
into text commands to be interpreted in a latex pgfpicture environment.
Attributes:
* figure: Matplotlib figure to initialize height, width and dpi from.
* fh: File handle for the output of the drawing commands.
"""
RendererBase.__init__(self)
self.dpi = figure.dpi
self.fh = fh
self.figure = figure
self.image_counter = 0
# get LatexManager instance
self.latexManager = LatexManagerFactory.get_latex_manager()
开发者ID:BlackEarth,项目名称:portable-python-win32,代码行数:17,代码来源:backend_pgf.py
示例15: start_filter
def start_filter(self):
return RendererBase.start_filter(self)
"""
Start filtering. It simply create a new canvas (the old one is saved).
"""
self._filter_renderers.append(self._renderer)
self._renderer = _RendererAgg(int(self.width), int(self.height),
self.dpi)
self._update_methods()
开发者ID:piScope,项目名称:piScope,代码行数:9,代码来源:renderer_gl.py
示例16: draw_path_collection
def draw_path_collection(self, gc, master_transform, paths, all_transforms,
offsets, offsetTrans, facecolors, edgecolors,
linewidths, linestyles, antialiaseds, urls,
offset_position):
# Is the optimization worth it? Rough calculation:
# cost of emitting a path in-line is
# (len_path + 5) * uses_per_path
# cost of definition+use is
# (len_path + 3) + 9 * uses_per_path
len_path = len(paths[0].vertices) if len(paths) > 0 else 0
uses_per_path = self._iter_collection_uses_per_path(
paths, all_transforms, offsets, facecolors, edgecolors)
should_do_optimization = \
len_path + 9 * uses_per_path + 3 < (len_path + 5) * uses_per_path
if not should_do_optimization:
return RendererBase.draw_path_collection(
self, gc, master_transform, paths, all_transforms,
offsets, offsetTrans, facecolors, edgecolors,
linewidths, linestyles, antialiaseds, urls,
offset_position)
writer = self.writer
path_codes = []
writer.start('defs')
for i, (path, transform) in enumerate(self._iter_collection_raw_paths(
master_transform, paths, all_transforms)):
transform = Affine2D(transform.get_matrix()).scale(1.0, -1.0)
d = self._convert_path(path, transform, simplify=False)
oid = 'C%x_%x_%s' % (self._path_collection_id, i,
self._make_id('', d))
writer.element('path', id=oid, d=d)
path_codes.append(oid)
writer.end('defs')
for xo, yo, path_id, gc0, rgbFace in self._iter_collection(
gc, master_transform, all_transforms, path_codes, offsets,
offsetTrans, facecolors, edgecolors, linewidths, linestyles,
antialiaseds, urls, offset_position):
clipid = self._get_clip(gc0)
url = gc0.get_url()
if url is not None:
writer.start('a', attrib={'xlink:href': url})
if clipid is not None:
writer.start('g', attrib={'clip-path': 'url(#%s)' % clipid})
attrib = {
'xlink:href': '#%s' % path_id,
'x': short_float_fmt(xo),
'y': short_float_fmt(self.height - yo),
'style': self._get_style(gc0, rgbFace)
}
writer.element('use', attrib=attrib)
if clipid is not None:
writer.end('g')
if url is not None:
writer.end('a')
self._path_collection_id += 1
开发者ID:4over7,项目名称:matplotlib,代码行数:57,代码来源:backend_svg.py
示例17: check
def check(master_transform, paths, all_transforms,
offsets, facecolors, edgecolors):
rb = RendererBase()
raw_paths = list(rb._iter_collection_raw_paths(
master_transform, paths, all_transforms))
gc = rb.new_gc()
ids = [path_id for xo, yo, path_id, gc0, rgbFace in
rb._iter_collection(gc, master_transform, all_transforms,
range(len(raw_paths)), offsets,
transforms.IdentityTransform(),
facecolors, edgecolors, [], [], [False],
[], 'data')]
uses = rb._iter_collection_uses_per_path(
paths, all_transforms, offsets, facecolors, edgecolors)
seen = [0] * len(raw_paths)
for i in ids:
seen[i] += 1
for n in seen:
assert n in (uses-1, uses)
开发者ID:Jajauma,项目名称:dotfiles,代码行数:19,代码来源:test_backend_bases.py
示例18: _draw_text_as_path
def _draw_text_as_path(self, renderer, gc, x, y, s, prop, angle, ismath):
path, transform = RendererBase._get_text_path_transform(renderer,
x, y, s,
prop, angle,
ismath)
color = gc.get_rgb()[:3]
gc.set_linewidth(0.0)
self.draw_path(renderer, gc, path, transform, rgbFace=color)
开发者ID:zoccolan,项目名称:eyetracker,代码行数:10,代码来源:patheffects.py
示例19: __init__
def __init__(self, width, height, dpi):
if __debug__:
verbose.report("RendererAgg.__init__", "debug-annoying")
RendererBase.__init__(self)
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:Kojoley,项目名称:matplotlib,代码行数:22,代码来源:backend_agg.py
示例20: draw_path_collection
def draw_path_collection(self, gc, master_transform, paths, all_transforms,
offsets, offsetTrans, facecolors, edgecolors,
linewidths, linestyles, antialiaseds, urls,
offset_position):
'''Draws a collection of paths selecting drawing properties from
the lists *facecolors*, *edgecolors*, *linewidths*,
*linestyles* and *antialiaseds*. *offsets* is a list of
offsets to apply to each of the paths. The offsets in
*offsets* are first transformed by *offsetTrans* before being
applied. *offset_position* may be either "screen" or "data"
depending on the space that the offsets are in.
'''
len_path = len(paths[0].vertices) if len(paths) > 0 else 0
uses_per_path = self._iter_collection_uses_per_path(
paths, all_transforms, offsets, facecolors, edgecolors)
# check whether an optimization is needed by calculating the cost of
# generating and use a path with the cost of emitting a path in-line.
should_do_optimization = \
len_path + uses_per_path + 5 < len_path * uses_per_path
if not should_do_optimization:
return RendererBase.draw_path_collection(
self, gc, master_transform, paths, all_transforms,
offsets, offsetTrans, facecolors, edgecolors,
linewidths, linestyles, antialiaseds, urls,
offset_position)
# Generate an array of unique paths with the respective transformations
path_codes = []
for i, (path, transform) in enumerate(self._iter_collection_raw_paths(
master_transform, paths, all_transforms)):
transform = Affine2D(transform.get_matrix()).scale(1.0, -1.0)
if _mpl_ge_2_0:
polygons = path.to_polygons(transform, closed_only=False)
else:
polygons = path.to_polygons(transform)
path_codes.append(polygons)
# Apply the styles and rgbFace to each one of the raw paths from
# the list. Additionally a transformation is being applied to
# translate each independent path
for xo, yo, path_poly, gc0, rgbFace in self._iter_collection(
gc, master_transform, all_transforms, path_codes, offsets,
offsetTrans, facecolors, edgecolors, linewidths, linestyles,
antialiaseds, urls, offset_position):
list_canvas_instruction = self.get_path_instructions(gc0, path_poly,
closed=True, rgbFace=rgbFace)
for widget, instructions in list_canvas_instruction:
widget.canvas.add(PushMatrix())
widget.canvas.add(Translate(xo, yo))
widget.canvas.add(instructions)
widget.canvas.add(PopMatrix())
开发者ID:janssen,项目名称:garden.matplotlib,代码行数:49,代码来源:backend_kivy.py
注:本文中的matplotlib.backend_bases.RendererBase类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论