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


Python Circle.set_label方法代码示例

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


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

示例1: print

# 需要导入模块: from matplotlib.patches import Circle [as 别名]
# 或者: from matplotlib.patches.Circle import set_label [as 别名]
(x, y) = (gps_lon[-1:], gps_lat[-1:])
# print (x, y)
# ax.plot returns a list of lines, so unpack tuple
l1, = ax.plot(x, y, 'r*', ms=8)

# anchor position platform lat and lon from config -- needs to be numpy.array([]) for ax.plot
(x, y) = (numpy.array([pi['lon']]), numpy.array([pi['lat']]))
# anchor posn platform lat and lon from netcdf file (should be the same as config)
# (x, y) = (nc.var('lon')[:], nc.var('lat')[:])
# print (x, y)
l2, = ax.plot(x, y, 'ks', ms=8, mfc='none')

# 1km watch circle, approx 111 km in 1 deg latitude 1 km is 1/111 of a deg
if 0:
    wc = Circle((x,y), 1./111, alpha=0.2)
    wc.set_label('1 km Watch Circle')
    p = PatchCollection([wc], alpha=0.2)
    ax.add_collection(p)
    leg1 = ax.legend([wc], ('1 km Watch Circle',), loc='lower left')

ax.set_xlabel('Longitude (deg)')
ax.set_ylabel('Latitude (deg)')
ax.axis('equal')

dx = numpy.diff(ax.get_xlim())
dy = numpy.diff(ax.get_ylim())

# how many degrees, how many minutes, how many seconds does this span
# (deg, mm, ss) = decdeg2dms(dx)
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
# if deg>0:
开发者ID:nccoos,项目名称:proc2plot,代码行数:33,代码来源:test_watch_circle.py

示例2: watch_circle

# 需要导入模块: from matplotlib.patches import Circle [as 别名]
# 或者: from matplotlib.patches.Circle import set_label [as 别名]
def watch_circle(pi, si, yyyy_mm, plot_type='latest'):
    """ 
    """
    print 'plot_cr1000_gps ...'
    img_dir = '/home/haines/rayleigh/img'

    prev_month, this_month, next_month = procutil.find_months(yyyy_mm)
    yyyy_mm_str = this_month.strftime('%Y_%m')

    fn = '_'.join([pi['id'], si['id'], prev_month.strftime('%Y_%m')+'.nc'])
    ncFile1= os.path.join(si['proc_dir'], fn)
    fn = '_'.join([pi['id'], si['id'], this_month.strftime('%Y_%m')+'.nc'])
    ncFile2= os.path.join(si['proc_dir'], fn)

    # ncFile1='/seacoos/data/nccoos/level1/meet/wq/meet_wq_'+prev_month.strftime('%Y_%m')+'.nc'
    # ncFile2='/seacoos/data/nccoos/level1/meet/wq/meet_wq_'+this_month.strftime('%Y_%m')+'.nc'

    have_ncFile1 = os.path.exists(ncFile1)
    have_ncFile2 = os.path.exists(ncFile2)

    print ' ... loading data for graph from ...'
    print ' ... ... ' + ncFile1 + ' ... ' + str(have_ncFile1)
    print ' ... ... ' + ncFile2 + ' ... ' + str(have_ncFile2)

    # open netcdf data
    if have_ncFile1 and have_ncFile2:
        nc = pycdf.CDFMF((ncFile1, ncFile2))
    elif not have_ncFile1 and have_ncFile2:
        nc = pycdf.CDFMF((ncFile2,))
    elif have_ncFile1 and not have_ncFile2:
        nc = pycdf.CDFMF((ncFile1,))
    else:
        print ' ... both files do not exist -- NO DATA LOADED'
        return

    # ncvars = nc.variables()
    # print ncvars
    es = nc.var('time')[:]
    units = nc.var('time').units
    dt = [procutil.es2dt(e) for e in es]
    # set timezone info to UTC (since data from level1 should be in UTC!!)
    dt = [e.replace(tzinfo=dateutil.tz.tzutc()) for e in dt]
    # return new datetime based on computer local
    dt_local = [e.astimezone(dateutil.tz.tzlocal()) for e in dt]
    dn = date2num(dt)

    # last dt in data for labels
    dtu = dt[-1]
    dtl = dt_local[-1]

    diff = abs(dtu - dtl)
    if diff.days>0:
        last_dt_str = dtu.strftime("%H:%M %Z on %b %d, %Y") + ' (' + dtl.strftime("%H:%M %Z, %b %d") + ')'
    else:
        last_dt_str = dtu.strftime("%H:%M %Z") + ' (' + dtl.strftime("%H:%M %Z") + ')' \
                      + dtl.strftime(" on %b %d, %Y")

    #######################################
    # Build Plot 
    #######################################

    fig = figure(figsize=(6, 5))
    fig.subplots_adjust(left=0.20, bottom=0.10, right=0.9, top=0.9, wspace=0.1, hspace=0.1)

    ax = fig.add_subplot(1,1,1)
    axs = [ax]

    # GPS longitude on x, latitude on y
    gps_lon = nc.var('gps_lon')[:]
    gps_lat = nc.var('gps_lat')[:]
    # gps_lon[-1:] returns last value as type numpy.array
    # gps_lon[-1] returns the value as type float
    (x, y) = (gps_lon[-1:], gps_lat[-1:])
    # print (x, y)
    # ax.plot returns a list of lines, so unpack tuple
    l1, = ax.plot(x, y, 'r*', ms=8)

    # anchor position platform lat and lon from config -- needs to be numpy.array([]) for ax.plot
    (x, y) = (numpy.array([pi['lon']]), numpy.array([pi['lat']]))
    # anchor posn platform lat and lon from netcdf file (should be the same as config)
    # (x, y) = (nc.var('lon')[:], nc.var('lat')[:])
    # print (x, y)
    l2, = ax.plot(x, y, 'ks', ms=8, mfc='none')

    # 1km watch circle, approx 111 km in 1 deg latitude 1 km is 1/111 of a deg
    if 0:
        wc = Circle((x,y), 1./111, alpha=0.2)
        wc.set_label('1 km Watch Circle')
        p = PatchCollection([wc], alpha=0.2)
        ax.add_collection(p)
        leg1 = ax.legend([wc], '1 km Watch Circle', loc='lower left')

    ax.set_xlabel('Longitude (deg)')
    ax.set_ylabel('Latitude (deg)')
    ax.axis('equal')

    # keep tick formatting from defaulting scienitific with offsets
    from matplotlib.ticker import FormatStrFormatter
    ax.xaxis.set_major_formatter(FormatStrFormatter('%g'))
    ax.yaxis.set_major_formatter(FormatStrFormatter('%g'))
#.........这里部分代码省略.........
开发者ID:nccoos,项目名称:proc2plot,代码行数:103,代码来源:plot_cr1000_gps.py


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