本文整理汇总了Python中matplotlib.transforms.blended_transform_factory方法的典型用法代码示例。如果您正苦于以下问题:Python transforms.blended_transform_factory方法的具体用法?Python transforms.blended_transform_factory怎么用?Python transforms.blended_transform_factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.transforms
的用法示例。
在下文中一共展示了transforms.blended_transform_factory方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: axes_hits
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import blended_transform_factory [as 别名]
def axes_hits(self, rect):
"""
rect : sequence of float
The dimensions [left, bottom, width, height] of the new axes. All
quantities are in fractions of figure width and height.
"""
# gene hits
ax2 = self.fig.add_axes(rect, sharex=self.ax)
# the x coords of this transformation are data, and the y coord are axes
trans2 = transforms.blended_transform_factory(ax2.transData, ax2.transAxes)
ax2.vlines(self._hit_indices, 0, 1, linewidth=.5, transform=trans2)
ax2.spines['bottom'].set_visible(False)
ax2.tick_params(axis='both', which='both',
bottom=False, top=False,
right=False, left=False,
labelbottom=False, labelleft=False)
示例2: _get_label
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import blended_transform_factory [as 别名]
def _get_label(self):
# x in axes coords, y in display coords (to be updated at draw
# time by _update_label_positions)
label = mtext.Text(x=0.5, y=0,
fontproperties=font_manager.FontProperties(
size=rcParams['axes.labelsize'],
weight=rcParams['axes.labelweight']),
color=rcParams['axes.labelcolor'],
verticalalignment='top',
horizontalalignment='center',
)
label.set_transform(mtransforms.blended_transform_factory(
self.axes.transAxes, mtransforms.IdentityTransform()))
self._set_artist_props(label)
self.label_position = 'bottom'
return label
示例3: _get_label
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import blended_transform_factory [as 别名]
def _get_label(self):
# x in axes coords, y in display coords (to be updated at draw
# time by _update_label_positions)
label = mtext.Text(x=0.5, y=0,
fontproperties=font_manager.FontProperties(
size=rcParams['axes.labelsize'],
weight=rcParams['axes.labelweight']),
color=rcParams['axes.labelcolor'],
verticalalignment='top',
horizontalalignment='center')
label.set_transform(mtransforms.blended_transform_factory(
self.axes.transAxes, mtransforms.IdentityTransform()))
self._set_artist_props(label)
self.label_position = 'bottom'
return label
示例4: fill_shaded_areas
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import blended_transform_factory [as 别名]
def fill_shaded_areas(self):
self.clean_collections()
if self.picked_pair:
mask = self.manager.get_nonoverlapping_segments(*self.picked_pair)
for ax in self.ax2, self.ax3:
ax.fill_between(
self.manager.times,
*ax.dataLim.intervaly,
mask,
facecolor="darkgray",
alpha=0.2,
)
trans = mtransforms.blended_transform_factory(
self.ax_slider.transData, self.ax_slider.transAxes
)
self.ax_slider.vlines(
np.flatnonzero(mask), 0, 0.5, color="darkorange", transform=trans
)
示例5: flag_frame
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import blended_transform_factory [as 别名]
def flag_frame(self, *args):
self.cuts.append(self.curr_frame)
self.ax_slider.axvline(self.curr_frame, color="r")
if len(self.cuts) == 2:
self.cuts.sort()
mask = np.zeros_like(self.manager.times, dtype=bool)
mask[self.cuts[0] : self.cuts[1] + 1] = True
for ax in self.ax2, self.ax3:
ax.fill_between(
self.manager.times,
*ax.dataLim.intervaly,
mask,
facecolor="darkgray",
alpha=0.2,
)
trans = mtransforms.blended_transform_factory(
self.ax_slider.transData, self.ax_slider.transAxes
)
self.ax_slider.vlines(
np.flatnonzero(mask), 0, 0.5, color="darkorange", transform=trans
)
self.fig.canvas.draw_idle()
示例6: axes_stat
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import blended_transform_factory [as 别名]
def axes_stat(self, rect):
"""
rect : sequence of float
The dimensions [left, bottom, width, height] of the new axes. All
quantities are in fractions of figure width and height.
"""
# Enrichment score plot
ax4 = self.fig.add_axes(rect)
ax4.plot(self._x, self.RES, linewidth=4, color ='#88C544')
ax4.text(.1, .1, self._fdr_label, transform=ax4.transAxes)
ax4.text(.1, .2, self._pval_label, transform=ax4.transAxes)
ax4.text(.1, .3, self._nes_label, transform=ax4.transAxes)
# the y coords of this transformation are data, and the x coord are axes
trans4 = transforms.blended_transform_factory(ax4.transAxes, ax4.transData)
ax4.hlines(0, 0, 1, linewidth=.5, transform=trans4, color='grey')
ax4.set_ylabel("Enrichment Score", fontsize=14)
#ax4.set_xlim(min(self._x), max(self._x))
ax4.tick_params(axis='both', which='both',
bottom=False, top=False, right=False,
labelbottom=False)
ax4.locator_params(axis='y', nbins=5)
# FuncFormatter need two argument, I don't know why. this lambda function used to format yaxis tick labels.
ax4.yaxis.set_major_formatter(
plt.FuncFormatter(lambda tick_loc,tick_num : '{:.1f}'.format(tick_loc)) )
self.ax = ax4
示例7: _get_offset_text
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import blended_transform_factory [as 别名]
def _get_offset_text(self):
# x in axes coords, y in display coords (to be updated at draw time)
offsetText = mtext.Text(x=1, y=0,
fontproperties=font_manager.FontProperties(
size=rcParams['xtick.labelsize']),
color=rcParams['xtick.color'],
verticalalignment='top',
horizontalalignment='right',
)
offsetText.set_transform(mtransforms.blended_transform_factory(
self.axes.transAxes, mtransforms.IdentityTransform()))
self._set_artist_props(offsetText)
self.offset_text_position = 'bottom'
return offsetText
示例8: set_position
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import blended_transform_factory [as 别名]
def set_position(self, position):
"""set the position of the spine
Spine position is specified by a 2 tuple of (position type,
amount). The position types are:
* 'outward' : place the spine out from the data area by the
specified number of points. (Negative values specify placing the
spine inward.)
* 'axes' : place the spine at the specified Axes coordinate (from
0.0-1.0).
* 'data' : place the spine at the specified data coordinate.
Additionally, shorthand notations define a special positions:
* 'center' -> ('axes',0.5)
* 'zero' -> ('data', 0.0)
"""
if position in ('center', 'zero'):
# special positions
pass
else:
assert len(position) == 2, "position should be 'center' or 2-tuple"
assert position[0] in ['outward', 'axes', 'data']
self._position = position
self._calc_offset_transform()
t = self.get_spine_transform()
if self.spine_type in ['left', 'right']:
t2 = mtransforms.blended_transform_factory(t,
self.axes.transData)
elif self.spine_type in ['bottom', 'top']:
t2 = mtransforms.blended_transform_factory(self.axes.transData,
t)
self.set_transform(t2)
if self.axis is not None:
self.axis.cla()
示例9: _set_lim_and_transforms
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import blended_transform_factory [as 别名]
def _set_lim_and_transforms(self):
self.transAxes = self._parent_axes.transAxes
self.transData = \
self.transAux + \
self._parent_axes.transData
self._xaxis_transform = mtransforms.blended_transform_factory(
self.transData, self.transAxes)
self._yaxis_transform = mtransforms.blended_transform_factory(
self.transAxes, self.transData)
示例10: _get_offset_text
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import blended_transform_factory [as 别名]
def _get_offset_text(self):
# x in axes coords, y in display coords (to be updated at draw time)
offsetText = mtext.Text(x=1, y=0,
fontproperties=font_manager.FontProperties(
size=rcParams['xtick.labelsize']),
color=rcParams['xtick.color'],
verticalalignment='top',
horizontalalignment='right')
offsetText.set_transform(mtransforms.blended_transform_factory(
self.axes.transAxes, mtransforms.IdentityTransform())
)
self._set_artist_props(offsetText)
self.offset_text_position = 'bottom'
return offsetText
示例11: get_spine_transform
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import blended_transform_factory [as 别名]
def get_spine_transform(self):
"""get the spine transform"""
self._ensure_position_is_set()
what, how = self._spine_transform
if what == 'data':
# special case data based spine locations
data_xform = self.axes.transScale + \
(how + self.axes.transLimits + self.axes.transAxes)
if self.spine_type in ['left', 'right']:
result = mtransforms.blended_transform_factory(
data_xform, self.axes.transData)
elif self.spine_type in ['top', 'bottom']:
result = mtransforms.blended_transform_factory(
self.axes.transData, data_xform)
else:
raise ValueError('unknown spine spine_type: %s' %
self.spine_type)
return result
if self.spine_type in ['left', 'right']:
base_transform = self.axes.get_yaxis_transform(which='grid')
elif self.spine_type in ['top', 'bottom']:
base_transform = self.axes.get_xaxis_transform(which='grid')
else:
raise ValueError('unknown spine spine_type: %s' %
self.spine_type)
if what == 'identity':
return base_transform
elif what == 'post':
return base_transform + how
elif what == 'pre':
return how + base_transform
else:
raise ValueError("unknown spine_transform type: %s" % what)
示例12: _update_transScale
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import blended_transform_factory [as 别名]
def _update_transScale(self):
self.transScale.set(
mtransforms.blended_transform_factory(
self.xaxis.get_transform(), self.yaxis.get_transform()))
for line in getattr(self, "lines", []): # Not set during init.
try:
line._transformed_path.invalidate()
except AttributeError:
pass