当前位置: 首页>>代码示例>>Python>>正文


Python Axes.scatter方法代码示例

本文整理汇总了Python中matplotlib.axes.Axes.scatter方法的典型用法代码示例。如果您正苦于以下问题:Python Axes.scatter方法的具体用法?Python Axes.scatter怎么用?Python Axes.scatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.axes.Axes的用法示例。


在下文中一共展示了Axes.scatter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: scatter

# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import scatter [as 别名]
 def scatter(self, xs, ys, zs=0, zdir='z', *args, **kwargs):
     '''
     Create a scatter plot.
     ==========  ================================================
     Argument    Description
     ==========  ================================================
     *xs*, *ys*  Positions of data points.
     *zs*        Either an array of the same length as *xs* and
                 *ys* or a single value to place all points in
                 the same plane. Default is 0.
     *zdir*      Which direction to use as z ('x', 'y' or 'z')
                 when plotting a 2d set.
     ==========  ================================================
     Keyword arguments are passed on to
     :func:`~matplotlib.axes.Axes.scatter`.
     Returns a :class:`~mpl_toolkits.mplot3d.art3d.Patch3DCollection`
     '''
     had_data = self.has_data()
     patches = Axes.scatter(self, xs, ys, *args, **kwargs)
     if not cbook.iterable(zs):
         is_2d = True
         zs = np.ones(len(xs)) * zs
     else:
         is_2d = False
     art3d.patch_collection_2d_to_3d(patches, zs=zs, zdir=zdir)
     if not is_2d:
         self.auto_scale_xyz(xs, ys, zs, had_data)
     return patches
开发者ID:,项目名称:,代码行数:30,代码来源:

示例2: scatter

# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import scatter [as 别名]
    def scatter(self, *args, **kwargs):
        """
        If the **mantid** projection is chosen, it can be
        used the same as :py:meth:`matplotlib.axes.Axes.scatter` for arrays,
        or it can be used to plot :class:`mantid.api.MatrixWorkspace`
        or :class:`mantid.api.IMDHistoWorkspace`. You can have something like::

            import matplotlib.pyplot as plt
            from mantid import plots

            ...

            fig, ax = plt.subplots(subplot_kw={'projection':'mantid'})
            ax.scatter(workspace,'rs',specNum=1) #for workspaces
            ax.scatter(x,y,'bo')                 #for arrays
            fig.show()

        For keywords related to workspaces, see :func:`plotfunctions.scatter`
        """
        if helperfunctions.validate_args(*args):
            logger.debug('using plotfunctions')
        else:
            return Axes.scatter(self, *args, **kwargs)
开发者ID:mantidproject,项目名称:mantid,代码行数:25,代码来源:__init__.py

示例3: scatter

# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import scatter [as 别名]
    def scatter(self, xs, ys, zs=0, zdir='z', s=20, c='b', *args, **kwargs):
        '''
        Create a scatter plot.

        ==========  ==========================================================
        Argument    Description
        ==========  ==========================================================
        *xs*, *ys*  Positions of data points.
        *zs*        Either an array of the same length as *xs* and
                    *ys* or a single value to place all points in
                    the same plane. Default is 0.
        *zdir*      Which direction to use as z ('x', 'y' or 'z')
                    when plotting a 2d set.
        *s*         size in points^2.  It is a scalar or an array of the same
                    length as *x* and *y*.

        *c*         a color. *c* can be a single color format string, or a
                    sequence of color specifications of length *N*, or a
                    sequence of *N* numbers to be mapped to colors using the
                    *cmap* and *norm* specified via kwargs (see below). Note
                    that *c* should not be a single numeric RGB or RGBA
                    sequence because that is indistinguishable from an array
                    of values to be colormapped.  *c* can be a 2-D array in
                    which the rows are RGB or RGBA, however.
        ==========  ==========================================================

        Keyword arguments are passed on to
        :func:`~matplotlib.axes.Axes.scatter`.

        Returns a :class:`~mpl_toolkits.mplot3d.art3d.Patch3DCollection`
        '''

        had_data = self.has_data()

        xs = np.ma.ravel(xs)
        ys = np.ma.ravel(ys)
        zs = np.ma.ravel(zs)
        if xs.size != ys.size:
            raise ValueError("x and y must be the same size")
        if xs.size != zs.size and zs.size == 1:
            zs = np.array(zs[0] * xs.size)

        s = np.ma.ravel(s)  # This doesn't have to match x, y in size.

        cstr = cbook.is_string_like(c) or cbook.is_sequence_of_strings(c)
        if not cstr:
            c = np.asanyarray(c)
            if c.size == xs.size:
                c = np.ma.ravel(c)

        xs, ys, zs, s, c = cbook.delete_masked_points(xs, ys, zs, s, c)

        patches = Axes.scatter(self, xs, ys, s=s, c=c, *args, **kwargs)
        if not cbook.iterable(zs):
            is_2d = True
            zs = np.ones(len(xs)) * zs
        else:
            is_2d = False
        art3d.patch_collection_2d_to_3d(patches, zs=zs, zdir=zdir)

        #FIXME: why is this necessary?
        if not is_2d:
            self.auto_scale_xyz(xs, ys, zs, had_data)

        return patches
开发者ID:CTPUG,项目名称:matplotlib,代码行数:67,代码来源:axes3d.py

示例4: plot_station_positions

# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import scatter [as 别名]
def plot_station_positions(directions_file_path: Path, stations: list, ax: Axes, grid_config: GridConfig=default_domains.bc_mh_044,
                           save_upstream_boundaries_to_shp=False):


    with Dataset(str(directions_file_path)) as ds:
        flow_dirs = ds.variables["flow_direction_value"][:]
        flow_acc_area = ds.variables["accumulation_area"][:]
        lons_2d, lats_2d = [ds.variables[k][:] for k in ["lon", "lat"]]



    basemap, reg_of_interest = grid_config.get_basemap_using_shape_with_polygons_of_interest(lons_2d, lats_2d,
                                                                                             shp_path=default_domains.MH_BASINS_PATH,
                                                                                             resolution="i")


    cell_manager = CellManager(flow_dirs, lons2d=lons_2d, lats2d=lats_2d, accumulation_area_km2=flow_acc_area)
    station_to_model_point = cell_manager.get_model_points_for_stations(station_list=stations, nneighbours=8)

    #####
    xx, yy = basemap(lons_2d, lats_2d)
    upstream_edges = cell_manager.get_upstream_polygons_for_points(
        model_point_list=list(station_to_model_point.values()), xx=xx, yy=yy)

    upstream_edges_latlon = cell_manager.get_upstream_polygons_for_points(
        model_point_list=list(station_to_model_point.values()), xx=lons_2d, yy=lats_2d)




    plot_utils.draw_upstream_area_bounds(ax, upstream_edges=upstream_edges, color="r", linewidth=0.6)

    if save_upstream_boundaries_to_shp:
        plot_utils.save_to_shape_file(upstream_edges_latlon, folder_path="mh/engage_report/upstream_stations_areas/mh_{}".format(grid_config.dx), in_proj=None)


    basemap.drawrivers(linewidth=0.2)
    basemap.drawstates(linewidth=0.1)
    basemap.drawcountries(linewidth=0.1)
    basemap.drawcoastlines(linewidth=0.2)


    pos_ids, lons_pos, lats_pos = [], [], []
    pos_labels = []
    legend_lines = []
    for i, (s, mp) in enumerate(sorted(station_to_model_point.items(), key=lambda p: p[0].latitude, reverse=True), start=1):
        pos_ids.append(s.id)
        pos_labels.append(i)
        lons_pos.append(mp.longitude)
        lats_pos.append(mp.latitude)

        legend_lines.append("{}: {}".format(i, s.id))

    xm, ym = basemap(lons_pos, lats_pos)
    ax.scatter(xm, ym, c="g", s=20)
    for txt, x1, y1, pos_label in zip(pos_ids, xm, ym, pos_labels):
        ax.annotate(pos_label, xy=(x1, y1))



    at = AnchoredText("\n".join(legend_lines), prop=dict(size=8), frameon=True, loc=1)

    at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
    ax.add_artist(at)
开发者ID:guziy,项目名称:RPN,代码行数:66,代码来源:station_positions_and_upstream_regions.py


注:本文中的matplotlib.axes.Axes.scatter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。