本文整理汇总了Python中geoplotlib.core.BatchPainter.labels方法的典型用法代码示例。如果您正苦于以下问题:Python BatchPainter.labels方法的具体用法?Python BatchPainter.labels怎么用?Python BatchPainter.labels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geoplotlib.core.BatchPainter
的用法示例。
在下文中一共展示了BatchPainter.labels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LabelsLayer
# 需要导入模块: from geoplotlib.core import BatchPainter [as 别名]
# 或者: from geoplotlib.core.BatchPainter import labels [as 别名]
class LabelsLayer(BaseLayer):
def __init__(self, data, label_column, color=None, font_name=FONT_NAME, font_size=14, anchor_x='left', anchor_y='top'):
"""Create a layer with a text label for each sample
:param data: data access object
:param label_column: column in the data access object where the labels text is stored
:param color: color
:param font_name: font name
:param font_size: font size
:param anchor_x: anchor x
:param anchor_y: anchor y
"""
self.data = data
self.label_column = label_column
self.color = color
self.font_name = font_name
self.font_size = font_size
self.anchor_x = anchor_x
self.anchor_y = anchor_y
if self.color is None:
self.color = [255,0,0]
def invalidate(self, proj):
self.painter = BatchPainter()
x, y = proj.lonlat_to_screen(self.data['lon'], self.data['lat'])
self.painter.set_color(self.color)
self.painter.labels(x, y, self.data[self.label_column],
font_name=self.font_name,
font_size=self.font_size,
anchor_x=self.anchor_x,
anchor_y=self.anchor_y)
def draw(self, proj, mouse_x, mouse_y, ui_manager):
self.painter.batch_draw()
def bbox(self):
return BoundingBox.from_points(lons=self.data['lon'], lats=self.data['lat'])