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


Python Basemap.set_axes_limits方法代码示例

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


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

示例1: map

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import set_axes_limits [as 别名]

#.........这里部分代码省略.........
        if md:
            slat = self.basemap.llcrnrlat + self.dlat - md
        else:
            slat = self.basemap.llcrnrlat
            nticks += 1
        lat_lines = np.arange(nticks) * self.dlat + slat
        self.basemap.drawparallels(lat_lines, color="0.5",
                                   linewidth=0.25, dashes=[1, 1, 0.1, 1],
                                   labels=[1, 0, 0, 0], fontsize=12)

    def land(self, color="black"):
        """
        Draw the land mask

        Parameters
        ----------
        color: string, optional
            color to draw the mask with
        """
        self.basemap.drawcoastlines()
        self.basemap.drawcountries()
        self.basemap.fillcontinents(color=color)

    def zoom(self, xrange, yrange):
        """
        zoom the figure to a specified lat, lon range

        Parameters
        ----------
        xrange: array
            minimum and maximum longitudes to display
        yrange: array
            minimum and maximum latitudes to display
        """
        x, y = self.basemap(xrange, yrange)
        self.ax.set_xlim(x)
        self.ax.set_ylim(y)
        self.fig.canvas.draw()

    def pcolormesh(self, lon, lat, data, **kwargs):
        """
        pcolormesh field data onto our geographic plot

        Parameters
        ----------
        lon: array
            Longitude field for data
        lat: array
            Latitude field for data
        data: array
            data to pcolor
        **kwargs: arguments, optional
            additional arguments to pass to pcolor
        """
        # Pcolor requires a modification to the locations to line up with
        # the geography
        dlon = lon * 0
        dlat = lat * 0
        dlon[:, 0:-1] = lon[:, 1:] - lon[:, 0:-1]
        dlat[0:-1, :] = lat[1:, :] - lat[0:-1, :]
        x, y = self.basemap(lon - dlon * 0.5, lat - dlat * 0.5)
        self.pc = self.ax.pcolormesh(x, y, data, **kwargs)

    def scatter(self, lon, lat, data, **kwargs):
        """
        scatter plot data onto our geographic plot

        Parameters
        ----------
        lon: array
            Longitude field for data
        lat: array
            Latitude field for data
        data: array
            data to pcolor
        **kwargs: arguments, optional
            additional arguments to pass to pcolor
        """
        x, y = self.basemap(lon, lat)
        self.pc = self.ax.scatter(x, y, c=data, **kwargs)

    def colorbar(self, label=None, cticks=None, **kwargs):
        """
        Display a colorbar on the figure

        Parameters
        ----------
        label: string, optional
            Colorbar label title
        cticks: array, optional
            Where to place the tick marks and values for the colorbar
        **kwargs: arguments, optional
            additional arguments to pass to colorbar
        """
        self.cax = self.fig.add_axes([0.25, 0.16, 0.5, 0.03])
        self.cb = plt.colorbar(self.pc, cax=self.cax, orientation="horizontal",
                               ticks=cticks, **kwargs)
        self.basemap.set_axes_limits(ax=self.ax)
        if label is not None:
            self.cb.set_label(label)
开发者ID:dalepartridge,项目名称:seapy,代码行数:104,代码来源:mapping.py

示例2: mch_animation

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import set_axes_limits [as 别名]

#.........这里部分代码省略.........
            self.ncg = netCDF.Dataset(grdfile)

        self.dates = netCDF.num2date(self.nc.variables['ocean_time'][:],
                                    'seconds since 1970-01-01')
        self.basemap = Basemap(llcrnrlon=-95.1,
                                llcrnrlat=27.25,
                                urcrnrlon=-87.5,
                                urcrnrlat=30.95,
                                projection='lcc',
                                lat_0=30.0,
                                lon_0=-90.0,
                                resolution ='i',
                                area_thresh=0.)

        os.system('mkdir %s' % self.framedir)
        self.frame = 0

    def new_frame(self, n):
        """docstring for new_frame"""
        self.n = n

        # set up figure and axis
        self.fig = plt.figure(figsize=self.figsize)
        self.ax = self.fig.add_axes([-0.01, 0.27, 1.01, 0.73])

        self.basemap.drawcoastlines(linewidth=0.25, color='k')
        self.basemap.fillcontinents(color='0.7')
        self.basemap.drawmeridians(range(-97, -85, 1), labels=[0, 0, 0, 0],
                                  color='0.5', linewidth=0.25)
        self.basemap.drawparallels(range(25, 32, 1), labels=[0, 0, 0, 0],
                                  color='0.5', linewidth=0.25)

        # get and plot date
        #datestr = str(n)
        datestr = self.dates[self.n].strftime('%Y %b %d %H:%M GMT')
        plt.text(0.02, 0.24, datestr+' ',
                fontproperties=self.font_fixed,
                horizontalalignment='left',
                verticalalignment='top',
                transform=self.fig.transFigure,
                fontsize=12)

    def close_frame(self):

        self.ax.set_axis_off()
        plt.savefig('%s/frame_%04d.png' % (self.framedir, self.frame), dpi=100)
        print ' ... wrote frame ', self.frame
        self.frame += 1
        plt.close(self.fig)

    def plot_vector_surface(self):
        decimate_factor = 60

        if self.frame == 0:
            lon = self.ncg.variables['lon_psi'][:]
            lat = self.ncg.variables['lat_psi'][:]
            xv, yv = self.basemap(lon, lat)
            self.xv, self.yv = xv, yv
            maskv = self.ncg.variables['mask_psi'][:]
            self.anglev = shrink(self.ncg.variables['angle'][:], xv.shape)
            idx, idy = np.where(maskv == 1.0)
            idv = np.arange(len(idx))
            np.random.shuffle(idv)
            Nvec = len(idx) / decimate_factor
            idv = idv[:Nvec]
            self.idx = idx[idv]
            self.idy = idy[idv]
            # save the grid locations as JSON file
            out_grdfile = 'grd_locations.json'
            grd = {'lon': lon[self.idx, self.idy].tolist(),
                   'lat': lat[self.idx, self.idy].tolist()}
            write_vector(grd, out_grdfile)
 
        u = self.nc.variables['u'][self.n, -1, :, :]
        v = self.nc.variables['v'][self.n, -1, :, :]
        u, v = shrink(u, v)
        u, v = rot2d(u, v, self.anglev)

        self.q = self.ax.quiver(self.xv[self.idx, self.idy],
        self.yv[self.idx, self.idy],
                                u[self.idx, self.idy],
                                v[self.idx, self.idy],
                                scale=20.0, pivot='middle',
                                zorder=1e35, alpha=0.25,
                                width=0.003)

        self.ax.quiverkey(self.q, 0.8, 0.90,
                          0.5, r'0.5 m s$^{-1}$', zorder=1e35)
        self.basemap.set_axes_limits(ax=self.ax)

        datestr = self.dates[self.n].strftime('%Y %b %d %H:%M GMT')
        vector = {'date': self.dates[self.n].isoformat(),
                  'u': u[self.idx, self.idy].tolist(),
                  'v': v[self.idx, self.idy].tolist()}
        return vector

    def __del__(self):
        """docstring for __del__"""
        self.nc.close()
        self.ncg.close()
开发者ID:hetland,项目名称:tabs,代码行数:104,代码来源:vector_animation.py

示例3: range

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import set_axes_limits [as 别名]
geoms = [ "ST_Simplify(ST_Buffer(ST_Buffer(\ngeom, -0.01),0.01),0.0025)",
         "ST_Simplify(ST_Buffer(ST_Buffer(\ngeom, -0.001),0.001),0.00025)",
         "geom", "ST_Simplify(geom,0.1)", "ST_Simplify(geom,0.01)"
         , "ST_Simplify(geom,0.001)"]

for row in range(2):
    for col in range(3):
        ax = axes[row,col]
        m = Basemap(projection='lcc', 
            urcrnrlat=ymax, llcrnrlat=ymin, 
            urcrnrlon=xmax, llcrnrlon=xmin, 
            lon_0=(xmax+xmin)/2., 
        lat_0=(ymax+ymin)/2.-5, lat_1=(ymax+ymin)/2., lat_2=(ymax+ymin)/2.+5,
        resolution='l', fix_aspect=True, ax=ax)
        #m.fillcontinents(color='b',zorder=0)
        m.set_axes_limits(ax=ax)
        g = geoms.pop()
        source = ogr.Open("PG:host=iemdb dbname=postgis")
        data = source.ExecuteSQL("select %s from nws_ugc where ugc = '%s'" % (g,
                                                                        UGC))

        patches = []
        while 1:
            feature = data.GetNextFeature()
            if not feature:
                break
            bindata = feature.GetGeometryRef().ExportToWkb()
            geom = loads(bindata)
            for polygon in geom:
                a = asarray(polygon.exterior)
                x,y = m(a[:,0], a[:,1])
开发者ID:KayneWest,项目名称:iem,代码行数:33,代码来源:map_ugc_simplify_change.py

示例4: map

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import set_axes_limits [as 别名]
               resolution = 'c')


x1, y1 = map(-60, -30)
x2, y2 = map(0, 0)
x3, y3 = map(45, 45)

plt.plot([x1, x2, x3], [y1, y2, y3], color='k', linestyle='-', linewidth=2)

ax1 = fig.add_axes([0.1, 0., 0.15, 0.15])
ax1.set_xticks([])
ax1.set_yticks([])

ax1.plot([x1, x2, x3], [y1, y2, y3], color='k', linestyle='-', linewidth=2)

map.set_axes_limits(ax=ax1)

ax2 = fig.add_axes([0.3, 0., 0.15, 0.15])
ax2.set_xticks([])
ax2.set_yticks([])

ax2.plot([x1, x2, x3], [y1, y2, y3], color='k', linestyle='-', linewidth=2)

ax3 = fig.add_axes([0.5, 0., 0.15, 0.15])
ax3.set_xticks([])
ax3.set_yticks([])

map.plot([x1, x2, x3], [y1, y2, y3], color='k', linestyle='-', linewidth=2, ax=ax3)

plt.show()
开发者ID:dansand,项目名称:vieps_mapping,代码行数:32,代码来源:set_axes_limits.py

示例5: sum

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import set_axes_limits [as 别名]
        )
        cx = 1 / (6 * area) * sum(
            (xy[i][0] + xy[i + 1][0]) * ((xy[i][0] * xy[i + 1][1]) - (xy[i + 1][0] * xy[i][1]))
            for i in range(len(xy) - 1)
        )
        cy = 1 / (6 * area) * sum(
            (xy[i][1] + xy[i + 1][1]) * ((xy[i][0] * xy[i + 1][1]) - (xy[i + 1][0] * xy[i][1]))
            for i in range(len(xy) - 1)
        )
        patches.append(matplotlib.patches.Polygon(xy))
        counts.append(count[name])
        # plt.text(cx, cy, name,
        #          horizontalalignment="center",
        #          verticalalignment="center")

m.set_axes_limits()

x, y = m(positions[1], positions[0])
plt.scatter(x, y, values, "k")

p = matplotlib.collections.PatchCollection(patches, cmap=colors, norm=normalize, alpha=0.7)
p.set_array(np.array(counts))
ax.add_collection(p)
plt.colorbar(p,
             spacing="proportional",
             ticks=range(max(counts) + 1),
             boundaries=range(max(counts) + 1))

plt.title("Anzahl der Schulen")
# plt.title(u"Anzahl der Grünflächen")
开发者ID:Datenschule,项目名称:EinsteigerWorkshop,代码行数:32,代码来源:test.py


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