本文整理汇总了Python中matplotlib.path.Path.make_compound_path_from_polys方法的典型用法代码示例。如果您正苦于以下问题:Python Path.make_compound_path_from_polys方法的具体用法?Python Path.make_compound_path_from_polys怎么用?Python Path.make_compound_path_from_polys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.path.Path
的用法示例。
在下文中一共展示了Path.make_compound_path_from_polys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeV
# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import make_compound_path_from_polys [as 别名]
def makeV(apex, angle, openingAngle, length, thickness):
verts = [apex]
verts.append(verts[-1] + length*vec(cos(angle-openingAngle/2), sin(angle-openingAngle/2)))
verts.append(verts[-1] + thickness*vec(cos(angle-openingAngle/2+pi/2), sin(angle-openingAngle/2+pi/2)))
verts.append(verts[-1] - (length-thickness/tan(openingAngle/2))*vec(cos(angle-openingAngle/2), sin(angle-openingAngle/2)))
verts.append(verts[-1] + (length-thickness/tan(openingAngle/2))*vec(cos(angle+openingAngle/2), sin(angle+openingAngle/2)))
verts.append(verts[-1] + thickness*vec(cos(angle+openingAngle/2+pi/2), sin(angle+openingAngle/2+pi/2)))
return verts
polys = []
for i in range(3):
for j in range(8):
polys.append(makeV((200*sigma + i*280*sigma, j*(60+9)*sigma), 0, pi/3, 60*sigma, 10*sigma))
polys.append(makeV((xmax - 200*sigma - i*280*sigma, j*(60+9)*sigma), pi, pi/3, 60*sigma, 10*sigma))
path = Path.make_compound_path_from_polys(np.array(polys))
# local swim speed
def v(i, inPoly):
if inPoly[i]:
return 0
else:
return v0
thetas = np.zeros(N)
xs = xmin + Lx*rnd.rand(N)
ys = ymin + Ly*rnd.rand(N)
points = np.array(list(zip(xs, ys)))
fig, ax = plt.subplots()
ax.set_xlim(xmin, xmax)
示例2: plot_ellipses_MacAdam1942_in_chromaticity_diagram
# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import make_compound_path_from_polys [as 别名]
def plot_ellipses_MacAdam1942_in_chromaticity_diagram(
chromaticity_diagram_callable=plot_chromaticity_diagram,
method='CIE 1931',
chromaticity_diagram_clipping=False,
ellipse_parameters=None,
**kwargs):
"""
Plots *MacAdam (1942) Ellipses (Observer PGN)* in the
*Chromaticity Diagram* according to given method.
Parameters
----------
chromaticity_diagram_callable : callable, optional
Callable responsible for drawing the *Chromaticity Diagram*.
method : unicode, optional
**{'CIE 1931', 'CIE 1960 UCS', 'CIE 1976 UCS'}**,
*Chromaticity Diagram* method.
chromaticity_diagram_clipping : bool, optional,
Whether to clip the *Chromaticity Diagram* colours with the ellipses.
ellipse_parameters : dict or array_like, optional
Parameters for the :class:`Ellipse` class, ``ellipse_parameters`` can
be either a single dictionary applied to all the ellipses with same
settings or a sequence of dictionaries with different settings for each
ellipse.
Other Parameters
----------------
\\**kwargs : dict, optional
{:func:`colour.plotting.artist`,
:func:`colour.plotting.diagrams.plot_chromaticity_diagram`,
:func:`colour.plotting.render`},
Please refer to the documentation of the previously listed definitions.
Returns
-------
tuple
Current figure and axes.
Examples
--------
>>> plot_ellipses_MacAdam1942_in_chromaticity_diagram() # doctest: +SKIP
.. image:: ../_static/\
Plotting_Plot_Ellipses_MacAdam1942_In_Chromaticity_Diagram.png
:align: center
:alt: plot_ellipses_MacAdam1942_in_chromaticity_diagram
"""
settings = {'uniform': True}
settings.update(kwargs)
_figure, axes = artist(**settings)
settings = dict(kwargs)
settings.update({'axes': axes, 'standalone': False})
ellipses_coefficients = ellipses_MacAdam1942(method=method)
if chromaticity_diagram_clipping:
diagram_clipping_path_x = []
diagram_clipping_path_y = []
for coefficients in ellipses_coefficients:
coefficients = np.copy(coefficients)
coefficients[2:4] /= 2
x, y = tsplit(
point_at_angle_on_ellipse(
np.linspace(0, 360, 36),
coefficients,
))
diagram_clipping_path_x.append(x)
diagram_clipping_path_y.append(y)
diagram_clipping_path = np.rollaxis(
np.array([diagram_clipping_path_x, diagram_clipping_path_y]), 0, 3)
diagram_clipping_path = Path.make_compound_path_from_polys(
diagram_clipping_path).vertices
settings.update({'diagram_clipping_path': diagram_clipping_path})
chromaticity_diagram_callable(**settings)
ellipse_settings_collection = [{
'color': COLOUR_STYLE_CONSTANTS.colour.cycle[4],
'alpha': 0.4,
'edgecolor': COLOUR_STYLE_CONSTANTS.colour.cycle[1],
'linewidth': colour_style()['lines.linewidth']
} for _ellipses_coefficient in ellipses_coefficients]
if ellipse_parameters is not None:
if not isinstance(ellipse_parameters, dict):
assert len(ellipse_parameters) == len(ellipses_coefficients), (
'Multiple ellipse parameters defined, but they do not match '
'the ellipses count!')
for i, ellipse_settings in enumerate(ellipse_settings_collection):
if isinstance(ellipse_parameters, dict):
ellipse_settings.update(ellipse_parameters)
else:
ellipse_settings.update(ellipse_parameters[i])
#.........这里部分代码省略.........