• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python maps.draw_name函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中maps.draw_name函数的典型用法代码示例。如果您正苦于以下问题:Python draw_name函数的具体用法?Python draw_name怎么用?Python draw_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: draw_centered_map

def draw_centered_map(center_state='TX', n=10):
	"""Draw the n states closest to center_state."""
	center = us_centers[center_state.upper()]
	dist_from_center = lambda name: geo_distance(center, us_centers[name])
	for name in sorted(us_states.keys(), key=dist_from_center)[:int(n)]:
		draw_state(us_states[name])
		draw_name(name, us_centers[name])
	draw_dot(center, 1, 10)  # Mark the center state with a red dot
	wait()
开发者ID:kevinchau321,项目名称:cs61a,代码行数:9,代码来源:trends.py


示例2: draw_centered_map

def draw_centered_map(center_state='TX', n=10):
    """Draw the n states closest to center_state."""
    centers = {name: find_state_center(us_states[name]) for name in us_states}
    center = centers[center_state.upper()]
    distance = lambda name: geo_distance(center, centers[name])
    for name in sorted(centers, key=distance)[:int(n)]:
        draw_state(us_states[name])
        draw_name(name, centers[name])
    draw_dot(center, 1, 10)  # Mark the center state with a red dot
    wait()
开发者ID:chenkc805,项目名称:CS61AProjects,代码行数:10,代码来源:trends.py


示例3: draw_centered_map

def draw_centered_map(center_state='TX', n=10, canvas=None):
    """Draw the n states closest to center_state."""
    us_centers = {n: find_center(s) for n, s in us_states.items()}
    center = us_centers[center_state.upper()]
    dist_from_center = lambda name: geo_distance(center, us_centers[name])
    for name in sorted(us_states.keys(), key=dist_from_center)[:int(n)]:
        draw_state(us_states[name], canvas=canvas)
        draw_name(name, us_centers[name], canvas=canvas)
    draw_dot(center, 1, 10, canvas=canvas)  # Mark the center state with a red dot
    wait(canvas=canvas)
开发者ID:aviadlevy,项目名称:Intro2cs-huji-2014,代码行数:10,代码来源:trends.py


示例4: draw_centered_map

def draw_centered_map(center_state='TX', n=10):
    """Draw the n states closest to center_state."""
    us_centers = make_database()
    for state, s in get_items(us_states):
        us_centers = add_value(us_centers, state, find_state_center(s))
    center = get_value_from_key(us_centers, center_state.upper()) 
    dist_from_center = lambda name: geo_distance(center, get_value_from_key(us_centers, name))
    for name in sorted(get_keys(us_centers), key=dist_from_center)[:int(n)]:
        draw_state(get_value_from_key(us_states, name))
        draw_name(name, get_value_from_key(us_centers, name))
    draw_dot(center, 1, 10)  # Mark the center state with a red dot
    wait()
开发者ID:wrahman1251,项目名称:Twitter-Trends,代码行数:12,代码来源:trends.py


示例5: draw_state_sentiments

def draw_state_sentiments(state_sentiments):
    """Draw all U.S. states in colors corresponding to their sentiment value.

    Unknown state names are ignored; states without values are colored grey.

    Arguments:
    state_sentiments -- A dictionary from state strings to sentiment values
    """
    for name, shapes in us_states.items():
        draw_state(shapes, state_sentiments.get(name))
    for name, shapes in us_states.items():
        center = find_state_center(shapes)
        if center is not None:
            draw_name(name, center)
开发者ID:chenkc805,项目名称:CS61AProjects,代码行数:14,代码来源:trends.py


示例6: draw_state_sentiments

def draw_state_sentiments(state_sentiments=make_idict()):
    """Draw all U.S. states in colors corresponding to their sentiment value.
    
    Unknown state names are ignored; states without values are colored grey.
    
    state_sentiments -- An immutable dictionary from state strings to sentiment values
    """
    for name, shapes in idict_items(us_states):
        sentiment = idict_select(state_sentiments, name)
        draw_state(shapes, sentiment)
    for name, shapes in idict_items(us_states):
        center = find_center(shapes)
        if center is not None:
            draw_name(name, center)
开发者ID:vgoklani,项目名称:Twitter-Trends-1,代码行数:14,代码来源:trends.py


示例7: draw_centered_map

def draw_centered_map(center_state='TX', n=10):
    """Draw the n states closest to center_state.
    
    For example, to draw the 20 states closest to California (including California):

    # python3 trends.py CA 20
    """
    us_centers = {n: find_center(s) for n, s in us_states.items()}
    center = us_centers[center_state.upper()]
    dist_from_center = lambda name: geo_distance(center, us_centers[name])
    for name in sorted(us_states.keys(), key=dist_from_center)[:int(n)]:
        draw_state(us_states[name])
        draw_name(name, us_centers[name])
    draw_dot(center, 1, 10)  # Mark the center state with a red dot
    wait()
开发者ID:PMX10,项目名称:projects,代码行数:15,代码来源:trends.py


示例8: draw_state_sentiments

def draw_state_sentiments(state_sentiments={}, canvas=None):
    """Draw all U.S. states in colors corresponding to their sentiment value.

    Unknown state names are ignored; states without values are colored grey.

    state_sentiments -- A dictionary from state strings to sentiment values
    """
    if canvas: clear(canvas=canvas)
    for name, shapes in us_states.items():
        sentiment = state_sentiments.get(name, None)
        draw_state(shapes, sentiment, canvas=canvas)
    for name, shapes in us_states.items():
        center = find_center(shapes)
        if center is not None:
            draw_name(name, center, canvas=canvas)
开发者ID:aviadlevy,项目名称:Intro2cs-huji-2014,代码行数:15,代码来源:trends.py


示例9: draw_state_sentiments

def draw_state_sentiments(state_sentiments):
    """Draw all U.S. states in colors corresponding to their sentiment value.

    Unknown state names are ignored; states without values are colored grey.

    state_sentiments -- A database from state strings to sentiment values
    """
    for name, shapes in get_items(us_states):
        if name in get_keys(state_sentiments):
            sentiment = get_value_from_key(state_sentiments, name)
        else:
            sentiment = None
        draw_state(shapes, sentiment)
    for name, shapes in get_items(us_states):
        center = find_state_center(shapes)
        if center is not None:
            draw_name(name, center)
开发者ID:wrahman1251,项目名称:Twitter-Trends,代码行数:17,代码来源:trends.py


示例10: draw_centered_map

def draw_centered_map(center_state='TX', n=10):
    """Draw the n states closest to center_state.
    
    For example, to draw the 20 states closest to California (including California),
    enter in the terminal: 

    # python3 trends.py CA 20
    """
    us_centers = make_idict()
    for i, s in idict_items(us_states):
        us_centers = idict_insert(us_centers, i, find_center(s))
    center = idict_select(us_centers, center_state.upper())
    dist_from_center = lambda name: geo_distance(center, idict_select(us_centers, name)) 
    for name in sorted(idict_keys(us_states), key=dist_from_center)[:int(n)]:
        draw_state(idict_select(us_states, name))
        draw_name(name, idict_select(us_centers, name))
    draw_dot(center, 1, 10)  # Mark the center state with a red dot
    wait()
开发者ID:anjishnu,项目名称:GeoProject,代码行数:18,代码来源:trends.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python maps.draw_state函数代码示例发布时间:2022-05-27
下一篇:
Python maps.draw_dot函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap