本文整理汇总了Python中matplotlib.collections.PatchCollection.set_offsets方法的典型用法代码示例。如果您正苦于以下问题:Python PatchCollection.set_offsets方法的具体用法?Python PatchCollection.set_offsets怎么用?Python PatchCollection.set_offsets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.collections.PatchCollection
的用法示例。
在下文中一共展示了PatchCollection.set_offsets方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_3d_projection
# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_offsets [as 别名]
def do_3d_projection(self, renderer):
xs, ys, zs = self._offsets3d
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs, renderer.M)
#FIXME: mpl allows us no way to unset the collection alpha value
self._alpha = None
self.set_facecolors(zalpha(self._facecolor3d, vzs))
self.set_edgecolors(zalpha(self._edgecolor3d, vzs))
PatchCollection.set_offsets(self, list(zip(vxs, vys)))
if vzs.size > 0 :
return min(vzs)
else :
return np.nan
示例2: do_3d_projection
# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_offsets [as 别名]
def do_3d_projection(self, renderer):
xs, ys, zs = self._offsets3d
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs, renderer.M)
fcs = zalpha(self._facecolor3d, vzs) if self._depthshade else self._facecolor3d
fcs = mcolors.colorConverter.to_rgba_array(fcs, self._alpha)
self.set_facecolors(fcs)
ecs = zalpha(self._edgecolor3d, vzs) if self._depthshade else self._edgecolor3d
ecs = mcolors.colorConverter.to_rgba_array(ecs, self._alpha)
self.set_edgecolors(ecs)
PatchCollection.set_offsets(self, list(zip(vxs, vys)))
if vzs.size > 0:
return min(vzs)
else:
return np.nan
示例3: render
# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_offsets [as 别名]
def render(self, patch_size=0.5, alpha=1.0, x_offset=100):
'''Draws the legend graphic and saves it to a file.'''
n = len(self.colors)
s = patch_size
# This offset is transformed to "data" coordinates (inches)
left_offset = (-s * 1.5) - (x_offset / self.dpi)
# Create grid to plot the artists
grid = np.concatenate((
np.zeros(n).reshape(n, 1),
np.arange(-n, 1)[1:].reshape(n, 1)
), axis=1)
plt.text(left_offset, 1.1, 'Legend', family='sans-serif',
size=14, weight='bold', color='#ffffff')
patches = []
for i in range(n):
# Add a rectangle
rect = mpatches.Rectangle(grid[i] - [0, 0], s, s, ec='none')
patches.append(rect)
self.__label__(grid[i], self.labels[i], x_offset)
collection = PatchCollection(patches, alpha=alpha)
# Space the patches and the text labels
collection.set_offset_position('data')
collection.set_offsets(np.array([
[left_offset, 0]
]))
collection.set_facecolors(self.colors)
#collection.set_edgecolor('#ffffff') # Draw color for box outlines
self.axis.add_collection(collection)
plt.axis('equal')
plt.axis('off')
plt.savefig(self.file_path, facecolor=self.bg_color, dpi=self.dpi,
pad_inches=0)
return self.file_path