本文整理汇总了Python中matplotlib.patheffects.PathEffectRenderer.new_gc方法的典型用法代码示例。如果您正苦于以下问题:Python PathEffectRenderer.new_gc方法的具体用法?Python PathEffectRenderer.new_gc怎么用?Python PathEffectRenderer.new_gc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patheffects.PathEffectRenderer
的用法示例。
在下文中一共展示了PathEffectRenderer.new_gc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: from matplotlib.patheffects import PathEffectRenderer [as 别名]
# 或者: from matplotlib.patheffects.PathEffectRenderer import new_gc [as 别名]
def draw(self, renderer):
"""draw the Line with `renderer` unless visibility is False"""
if not self.get_visible():
return
if self._invalidy or self._invalidx:
self.recache()
self.ind_offset = 0 # Needed for contains() method.
if self._subslice and self.axes:
x0, x1 = self.axes.get_xbound()
i0, = self._x_filled.searchsorted([x0], 'left')
i1, = self._x_filled.searchsorted([x1], 'right')
subslice = slice(max(i0 - 1, 0), i1 + 1)
self.ind_offset = subslice.start
self._transform_path(subslice)
transf_path = self._get_transformed_path()
if self.get_path_effects():
from matplotlib.patheffects import PathEffectRenderer
renderer = PathEffectRenderer(self.get_path_effects(), renderer)
renderer.open_group('line2d', self.get_gid())
funcname = self._lineStyles.get(self._linestyle, '_draw_nothing')
if funcname != '_draw_nothing':
tpath, affine = transf_path.get_transformed_path_and_affine()
if len(tpath.vertices):
self._lineFunc = getattr(self, funcname)
funcname = self.drawStyles.get(self._drawstyle, '_draw_lines')
drawFunc = getattr(self, funcname)
gc = renderer.new_gc()
self._set_gc_clip(gc)
ln_color_rgba = self._get_rgba_ln_color()
gc.set_foreground(ln_color_rgba, isRGBA=True)
gc.set_alpha(ln_color_rgba[3])
gc.set_antialiased(self._antialiased)
gc.set_linewidth(self._linewidth)
if self.is_dashed():
cap = self._dashcapstyle
join = self._dashjoinstyle
else:
cap = self._solidcapstyle
join = self._solidjoinstyle
gc.set_joinstyle(join)
gc.set_capstyle(cap)
gc.set_snap(self.get_snap())
if self.get_sketch_params() is not None:
gc.set_sketch_params(*self.get_sketch_params())
drawFunc(renderer, gc, tpath, affine.frozen())
gc.restore()
if self._marker and self._markersize > 0:
gc = renderer.new_gc()
self._set_gc_clip(gc)
rgbaFace = self._get_rgba_face()
rgbaFaceAlt = self._get_rgba_face(alt=True)
edgecolor = self.get_markeredgecolor()
if is_string_like(edgecolor) and edgecolor.lower() == 'none':
gc.set_linewidth(0)
gc.set_foreground(rgbaFace, isRGBA=True)
else:
gc.set_foreground(edgecolor)
gc.set_linewidth(self._markeredgewidth)
mec = self._markeredgecolor
if (is_string_like(mec) and mec == 'auto' and
rgbaFace is not None):
gc.set_alpha(rgbaFace[3])
else:
gc.set_alpha(self.get_alpha())
marker = self._marker
tpath, affine = transf_path.get_transformed_points_and_affine()
if len(tpath.vertices):
# subsample the markers if markevery is not None
markevery = self.get_markevery()
if markevery is not None:
subsampled = _mark_every_path(markevery, tpath,
affine, self.axes.transAxes)
else:
subsampled = tpath
snap = marker.get_snap_threshold()
if type(snap) == float:
snap = renderer.points_to_pixels(self._markersize) >= snap
gc.set_snap(snap)
gc.set_joinstyle(marker.get_joinstyle())
gc.set_capstyle(marker.get_capstyle())
marker_path = marker.get_path()
marker_trans = marker.get_transform()
w = renderer.points_to_pixels(self._markersize)
if marker.get_marker() != ',':
# Don't scale for pixels, and don't stroke them
marker_trans = marker_trans.scale(w)
else:
gc.set_linewidth(0)
#.........这里部分代码省略.........
示例2: draw
# 需要导入模块: from matplotlib.patheffects import PathEffectRenderer [as 别名]
# 或者: from matplotlib.patheffects.PathEffectRenderer import new_gc [as 别名]
def draw(self, renderer):
"""draw the Line with `renderer` unless visibility is False"""
if not self.get_visible():
return
if self._invalidy or self._invalidx:
self.recache()
self.ind_offset = 0 # Needed for contains() method.
if self._subslice and self.axes:
x0, x1 = self.axes.get_xbound()
i0, = self._x_filled.searchsorted([x0], 'left')
i1, = self._x_filled.searchsorted([x1], 'right')
subslice = slice(max(i0 - 1, 0), i1 + 1)
self.ind_offset = subslice.start
self._transform_path(subslice)
else:
subslice = None
if self.get_path_effects():
from matplotlib.patheffects import PathEffectRenderer
renderer = PathEffectRenderer(self.get_path_effects(), renderer)
renderer.open_group('line2d', self.get_gid())
if self._lineStyles[self._linestyle] != '_draw_nothing':
tpath, affine = (self._get_transformed_path()
.get_transformed_path_and_affine())
if len(tpath.vertices):
gc = renderer.new_gc()
self._set_gc_clip(gc)
lc_rgba = mcolors.to_rgba(self._color, self._alpha)
gc.set_foreground(lc_rgba, isRGBA=True)
gc.set_antialiased(self._antialiased)
gc.set_linewidth(self._linewidth)
if self.is_dashed():
cap = self._dashcapstyle
join = self._dashjoinstyle
else:
cap = self._solidcapstyle
join = self._solidjoinstyle
gc.set_joinstyle(join)
gc.set_capstyle(cap)
gc.set_snap(self.get_snap())
if self.get_sketch_params() is not None:
gc.set_sketch_params(*self.get_sketch_params())
gc.set_dashes(self._dashOffset, self._dashSeq)
renderer.draw_path(gc, tpath, affine.frozen())
gc.restore()
if self._marker and self._markersize > 0:
gc = renderer.new_gc()
self._set_gc_clip(gc)
gc.set_linewidth(self._markeredgewidth)
gc.set_antialiased(self._antialiased)
ec_rgba = mcolors.to_rgba(
self.get_markeredgecolor(), self._alpha)
fc_rgba = mcolors.to_rgba(
self._get_markerfacecolor(), self._alpha)
fcalt_rgba = mcolors.to_rgba(
self._get_markerfacecolor(alt=True), self._alpha)
# If the edgecolor is "auto", it is set according to the *line*
# color but inherits the alpha value of the *face* color, if any.
if (cbook._str_equal(self._markeredgecolor, "auto")
and not cbook._str_lower_equal(
self.get_markerfacecolor(), "none")):
ec_rgba = ec_rgba[:3] + (fc_rgba[3],)
gc.set_foreground(ec_rgba, isRGBA=True)
marker = self._marker
# Markers *must* be drawn ignoring the drawstyle (but don't pay the
# recaching if drawstyle is already "default").
if self.get_drawstyle() != "default":
with cbook._setattr_cm(
self, _drawstyle="default", _transformed_path=None):
self.recache()
self._transform_path(subslice)
tpath, affine = (self._get_transformed_path()
.get_transformed_path_and_affine())
else:
tpath, affine = (self._get_transformed_path()
.get_transformed_path_and_affine())
if len(tpath.vertices):
# subsample the markers if markevery is not None
markevery = self.get_markevery()
if markevery is not None:
subsampled = _mark_every_path(markevery, tpath,
affine, self.axes.transAxes)
else:
subsampled = tpath
snap = marker.get_snap_threshold()
if type(snap) == float:
snap = renderer.points_to_pixels(self._markersize) >= snap
gc.set_snap(snap)
#.........这里部分代码省略.........