本文整理汇总了Python中matplotlib.patches.PathPatch.set_facecolor方法的典型用法代码示例。如果您正苦于以下问题:Python PathPatch.set_facecolor方法的具体用法?Python PathPatch.set_facecolor怎么用?Python PathPatch.set_facecolor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.PathPatch
的用法示例。
在下文中一共展示了PathPatch.set_facecolor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_path
# 需要导入模块: from matplotlib.patches import PathPatch [as 别名]
# 或者: from matplotlib.patches.PathPatch import set_facecolor [as 别名]
def make_path(d, style):
items = []
for c in d.split():
if c.upper() in codemap:
items.append(c)
else:
x, y = (float(v) for v in c.split(","))
items.append((x, y))
codes = []
vertices = []
i = 0
lx, ly = 0, 0
last_code = "M"
while i < len(items):
code = items[i]
if not isinstance(code, str):
code = last_code
else:
i += 1
ucode = code.upper()
if code.isupper():
relative = False
else:
relative = True
if ucode in ("M", "L"):
x, y = items[i]
i += 1
if relative:
x += lx
y += ly
codes.append(codemap[ucode])
vertices.append((x, y))
lx, ly = x, y
if ucode == "C":
if not relative:
points = items[i:i+3]
else:
points = [(_x + lx, _y + ly) for _x, _y in items[i:i+3]]
codes.extend([codemap[ucode]]*3)
vertices.extend(points)
lx, ly = points[-1]
i += 3
if ucode == "Z":
break
last_code = code
codes[0] = Path.MOVETO
patch = PathPatch( Path(vertices, codes) )
patch.set_linewidth( get_number(style.get("stroke-width", "1px") ) )
fill = style.get("fill", "none")
if fill == "none":
patch.set_fill( None )
else:
patch.set_facecolor( fill )
edge = style.get("stroke", "none")
patch.set_edgecolor(edge)
return patch
示例2: _render_on_subplot
# 需要导入模块: from matplotlib.patches import PathPatch [as 别名]
# 或者: from matplotlib.patches.PathPatch import set_facecolor [as 别名]
def _render_on_subplot(self, subplot):
"""
Render this Bezier path in a subplot. This is the key function that
defines how this Bezier path graphics primitive is rendered in matplotlib's
library.
TESTS::
sage: bezier_path([[(0,1),(.5,0),(1,1)]])
Graphics object consisting of 1 graphics primitive
::
sage: bezier_path([[(0,1),(.5,0),(1,1),(-3,5)]])
Graphics object consisting of 1 graphics primitive
"""
from matplotlib.patches import PathPatch
from matplotlib.path import Path
from sage.plot.misc import get_matplotlib_linestyle
options = dict(self.options())
del options['alpha']
del options['thickness']
del options['rgbcolor']
del options['zorder']
del options['fill']
del options['linestyle']
bpath = Path(self.vertices, self.codes)
bpatch = PathPatch(bpath, **options)
options = self.options()
bpatch.set_linewidth(float(options['thickness']))
bpatch.set_fill(options['fill'])
bpatch.set_zorder(options['zorder'])
a = float(options['alpha'])
bpatch.set_alpha(a)
c = to_mpl_color(options['rgbcolor'])
bpatch.set_edgecolor(c)
bpatch.set_facecolor(c)
bpatch.set_linestyle(get_matplotlib_linestyle(options['linestyle'], return_type='long'))
subplot.add_patch(bpatch)
示例3: ColorbarBase
# 需要导入模块: from matplotlib.patches import PathPatch [as 别名]
# 或者: from matplotlib.patches.PathPatch import set_facecolor [as 别名]
#.........这里部分代码省略.........
set label.
"""
self.cbar_axis.set_label_text(self._label, **self._labelkw)
def set_label_text(self, label, **kw):
'''
Label the long axis of the colorbar
'''
self._label = label
self._labelkw = kw
self._set_label_text()
def _edges(self, X, Y):
'''
Return the separator line segments; helper for _add_solids.
'''
N = X.shape[0]
# Using the non-array form of these line segments is much
# simpler than making them into arrays.
if self.orientation == 'vertical':
return [list(zip(X[i], Y[i])) for i in range(1, N-1)]
else:
return [list(zip(Y[i], X[i])) for i in range(1, N-1)]
def _add_solids(self, X, Y, C):
'''
Draw the colors using :meth:`~matplotlib.axes.Axes.pcolormesh`;
optionally add separators.
'''
## Change to pcolorfast after fixing bugs in some backends...
if self.extend in ["min", "both"]:
cc = self.to_rgba([C[0][0]])
self.extension_patch1.set_facecolor(cc[0])
X, Y, C = X[1:], Y[1:], C[1:]
if self.extend in ["max", "both"]:
cc = self.to_rgba([C[-1][0]])
self.extension_patch2.set_facecolor(cc[0])
X, Y, C = X[:-1], Y[:-1], C[:-1]
if self.orientation == 'vertical':
args = (X, Y, C)
else:
args = (np.transpose(Y), np.transpose(X), np.transpose(C))
del self.solids
del self.dividers
col = self.ax.pcolormesh(
*args,
cmap=self.cmap, norm=self.norm, shading='flat', alpha=self.alpha)
self.solids = col
if self.drawedges:
self.dividers = collections.LineCollection(
self._edges(X, Y),
colors=(mpl.rcParams['axes.edgecolor'],),
linewidths=(0.5*mpl.rcParams['axes.linewidth'],),
)
self.ax.add_collection(self.dividers)
else:
self.dividers = None
def add_lines(self, levels, colors, linewidths):
'''