def draw_strip_text(self, text_lines, location, pid):
"""
Create a background patch and put a label on it
"""
ax = self.axs[pid]
themeable = self.figure._themeable
dim = self.strip_dimensions(text_lines, location, pid)
if location == 'right':
rotation = -90
label = '\n'.join(reversed(text_lines))
else:
rotation = 0
label = '\n'.join(text_lines)
rect = mpatch.FancyBboxPatch((dim.box_x, dim.box_y),
width=dim.box_width,
height=dim.box_height,
facecolor='lightgrey',
edgecolor='None',
transform=ax.transAxes,
zorder=2.2, # > ax line & boundary
boxstyle='square, pad=0',
clip_on=False)
text = mtext.Text(dim.x, dim.y, label,
rotation=rotation,
verticalalignment='center',
horizontalalignment='center',
transform=ax.transAxes,
zorder=3.3, # > rect
clip_on=False)
ax.add_artist(rect)
ax.add_artist(text)
for key in ('strip_text_x', 'strip_text_y',
'strip_background_x', 'strip_background_y'):
if key not in themeable:
themeable[key] = []
if location == 'right':
themeable['strip_background_y'].append(rect)
themeable['strip_text_y'].append(text)
else:
themeable['strip_background_x'].append(rect)
themeable['strip_text_x'].append(text)
评论列表
文章目录