stereonet_axes.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:qgis-stereonet 作者: daniel-childs 项目源码 文件源码
def cone(self, plunge, bearing, angle, segments=100, bidirectional=True,
             **kwargs):
        """
        Plot a polygon of a small circle (a.k.a. a cone) with an angular radius
        of *angle* centered at a p/b of *plunge*, *bearing*. Additional keyword
        arguments are passed on to the ``PathCollection``.  (e.g. to have an
        unfilled small small circle, pass "facecolor='none'".)

        Parameters
        ----------
        plunge : number or sequence of numbers
            The plunge of the center of the cone in degrees.
        bearing : number or sequence of numbers
            The bearing of the center of the cone in degrees.
        angle : number or sequence of numbers
            The angular radius of the cone in degrees.
        segments : int, optional
            The number of vertices to use for the cone. Defaults to 100.
        bidirectional : boolean, optional
            Whether or not to draw two patches (the one given and its antipode)
            for each measurement. Defaults to True.
        **kwargs
            Additional parameters are ``matplotlib.collections.PatchCollection``
            properties.

        Returns
        -------
        collection : ``matplotlib.collections.PathCollection``

        Notes
        -----
        If *bidirectional* is ``True``, two circles will be plotted, even if
        only one of each pair is visible. This is the default behavior.
        """
        plunge, bearing, angle = np.atleast_1d(plunge, bearing, angle)
        patches = []
        lons, lats = stereonet_math.cone(plunge, bearing, angle, segments)
        codes = mpath.Path.LINETO * np.ones(segments, dtype=np.uint8)
        codes[0] = mpath.Path.MOVETO

        if bidirectional:
            p, b = -plunge, bearing + 180
            alons, alats = stereonet_math.cone(p, b, angle, segments)
            codes = np.hstack([codes, codes])
            lons = np.hstack([lons, alons])
            lats = np.hstack([lats, alats])

        for lon, lat in zip(lons, lats):
            xy = np.vstack([lon, lat]).T
            path = mpath.Path(xy, codes)
            patches.append(mpatches.PathPatch(path))

        col = mcollections.PatchCollection(patches, **kwargs)
        self.add_collection(col)
        return col
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号