Python matplotlib.transforms.blended_transform_factory() Examples
The following are 30
code examples of matplotlib.transforms.blended_transform_factory().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.transforms
, or try the search function
.
Example #1
Source File: axis.py From matplotlib-4-abaqus with MIT License | 6 votes |
def _get_label(self): # x in display coords (updated by _update_label_position) # y in axes coords label = mtext.Text(x=0, y=0.5, # todo: get the label position fontproperties=font_manager.FontProperties( size=rcParams['axes.labelsize'], weight=rcParams['axes.labelweight']), color=rcParams['axes.labelcolor'], verticalalignment='bottom', horizontalalignment='center', rotation='vertical', rotation_mode='anchor', ) label.set_transform(mtransforms.blended_transform_factory( mtransforms.IdentityTransform(), self.axes.transAxes)) self._set_artist_props(label) self.label_position = 'left' return label
Example #2
Source File: axis.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
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
Example #3
Source File: axis.py From CogAlg with MIT License | 6 votes |
def _get_label(self): # x in display coords (updated by _update_label_position) # y in axes coords label = mtext.Text(x=0, y=0.5, # todo: get the label position fontproperties=font_manager.FontProperties( size=rcParams['axes.labelsize'], weight=rcParams['axes.labelweight']), color=rcParams['axes.labelcolor'], verticalalignment='bottom', horizontalalignment='center', rotation='vertical', rotation_mode='anchor') label.set_transform(mtransforms.blended_transform_factory( mtransforms.IdentityTransform(), self.axes.transAxes)) self._set_artist_props(label) self.label_position = 'left' return label
Example #4
Source File: axis.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def _get_label(self): # x in display coords (updated by _update_label_position) # y in axes coords label = mtext.Text(x=0, y=0.5, # todo: get the label position fontproperties=font_manager.FontProperties( size=rcParams['axes.labelsize'], weight=rcParams['axes.labelweight']), color=rcParams['axes.labelcolor'], verticalalignment='bottom', horizontalalignment='center', rotation='vertical', rotation_mode='anchor') label.set_transform(mtransforms.blended_transform_factory( mtransforms.IdentityTransform(), self.axes.transAxes)) self._set_artist_props(label) self.label_position = 'left' return label
Example #5
Source File: axis.py From CogAlg with MIT License | 6 votes |
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
Example #6
Source File: axis.py From coffeegrindsize with MIT License | 6 votes |
def _get_label(self): # x in display coords (updated by _update_label_position) # y in axes coords label = mtext.Text(x=0, y=0.5, # todo: get the label position fontproperties=font_manager.FontProperties( size=rcParams['axes.labelsize'], weight=rcParams['axes.labelweight']), color=rcParams['axes.labelcolor'], verticalalignment='bottom', horizontalalignment='center', rotation='vertical', rotation_mode='anchor') label.set_transform(mtransforms.blended_transform_factory( mtransforms.IdentityTransform(), self.axes.transAxes)) self._set_artist_props(label) self.label_position = 'left' return label
Example #7
Source File: plot.py From GSEApy with BSD 3-Clause "New" or "Revised" License | 6 votes |
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)
Example #8
Source File: axis.py From matplotlib-4-abaqus with MIT License | 6 votes |
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
Example #9
Source File: axis.py From coffeegrindsize with MIT License | 6 votes |
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
Example #10
Source File: axis.py From neural-network-animation with MIT License | 6 votes |
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
Example #11
Source File: axis.py From neural-network-animation with MIT License | 6 votes |
def _get_label(self): # x in display coords (updated by _update_label_position) # y in axes coords label = mtext.Text(x=0, y=0.5, # todo: get the label position fontproperties=font_manager.FontProperties( size=rcParams['axes.labelsize'], weight=rcParams['axes.labelweight']), color=rcParams['axes.labelcolor'], verticalalignment='bottom', horizontalalignment='center', rotation='vertical', rotation_mode='anchor', ) label.set_transform(mtransforms.blended_transform_factory( mtransforms.IdentityTransform(), self.axes.transAxes)) self._set_artist_props(label) self.label_position = 'left' return label
Example #12
Source File: tracklets.py From DeepLabCut with GNU Lesser General Public License v3.0 | 6 votes |
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()
Example #13
Source File: tracklets.py From DeepLabCut with GNU Lesser General Public License v3.0 | 6 votes |
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 )
Example #14
Source File: axis.py From GraphicDesignPatternByPython with MIT License | 6 votes |
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
Example #15
Source File: axis.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def _get_label(self): # x in display coords (updated by _update_label_position) # y in axes coords label = mtext.Text(x=0, y=0.5, # todo: get the label position fontproperties=font_manager.FontProperties( size=rcParams['axes.labelsize'], weight=rcParams['axes.labelweight']), color=rcParams['axes.labelcolor'], verticalalignment='bottom', horizontalalignment='center', rotation='vertical', rotation_mode='anchor') label.set_transform(mtransforms.blended_transform_factory( mtransforms.IdentityTransform(), self.axes.transAxes)) self._set_artist_props(label) self.label_position = 'left' return label
Example #16
Source File: axis.py From ImageFusion with MIT License | 6 votes |
def _get_label(self): # x in display coords (updated by _update_label_position) # y in axes coords label = mtext.Text(x=0, y=0.5, # todo: get the label position fontproperties=font_manager.FontProperties( size=rcParams['axes.labelsize'], weight=rcParams['axes.labelweight']), color=rcParams['axes.labelcolor'], verticalalignment='bottom', horizontalalignment='center', rotation='vertical', rotation_mode='anchor', ) label.set_transform(mtransforms.blended_transform_factory( mtransforms.IdentityTransform(), self.axes.transAxes)) self._set_artist_props(label) self.label_position = 'left' return label
Example #17
Source File: axis.py From ImageFusion with MIT License | 6 votes |
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
Example #18
Source File: axis.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #19
Source File: axis.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _get_label(self): # x in display coords (updated by _update_label_position) # y in axes coords label = mtext.Text(x=0, y=0.5, # todo: get the label position fontproperties=font_manager.FontProperties( size=rcParams['axes.labelsize'], weight=rcParams['axes.labelweight']), color=rcParams['axes.labelcolor'], verticalalignment='bottom', horizontalalignment='center', rotation='vertical', rotation_mode='anchor') label.set_transform(mtransforms.blended_transform_factory( mtransforms.IdentityTransform(), self.axes.transAxes)) self._set_artist_props(label) self.label_position = 'left' return label
Example #20
Source File: utils.py From scvelo with BSD 3-Clause "New" or "Revised" License | 5 votes |
def plot_rug(x, height=0.03, color=None, ax=None, **kwargs): if ax is None: ax = pl.gca() x = np.asarray(x) transform = tx.blended_transform_factory(ax.transData, ax.transAxes) line_segs = np.column_stack( [np.repeat(x, 2), np.tile([0, height], len(x))] ).reshape([len(x), 2, 2]) kwargs.update({"transform": transform, "color": color}) ax.add_collection(LineCollection(line_segs, **kwargs)) ax.autoscale_view(scalex=True, scaley=False)
Example #21
Source File: spines.py From CogAlg with MIT License | 5 votes |
def get_spine_transform(self): """Return 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)
Example #22
Source File: axis.py From CogAlg with MIT License | 5 votes |
def _get_offset_text(self): # x in display coords, y in axes coords (to be updated at draw time) offsetText = mtext.Text(x=0, y=0.5, fontproperties=font_manager.FontProperties( size=rcParams['ytick.labelsize'] ), color=rcParams['ytick.color'], verticalalignment='baseline', horizontalalignment='left') offsetText.set_transform(mtransforms.blended_transform_factory( self.axes.transAxes, mtransforms.IdentityTransform()) ) self._set_artist_props(offsetText) self.offset_text_position = 'left' return offsetText
Example #23
Source File: test_transforms.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_line_extent_compound_coords1(self): # a simple line in data coordinates in the y component, and in axes # coordinates in the x ax = plt.axes() trans = mtransforms.blended_transform_factory(ax.transAxes, ax.transData) ax.plot([0.1, 1.2, 0.8], [35, -5, 18], transform=trans) assert_array_equal(ax.dataLim.get_points(), np.array([[np.inf, -5.], [-np.inf, 35.]])) plt.close()
Example #24
Source File: test_skew.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _set_lim_and_transforms(self): """ This is called once when the plot is created to set up all the transforms for the data, text and grids. """ rot = 30 # Get the standard transform setup from the Axes base class Axes._set_lim_and_transforms(self) # Need to put the skew in the middle, after the scale and limits, # but before the transAxes. This way, the skew is done in Axes # coordinates thus performing the transform around the proper origin # We keep the pre-transAxes transform around for other users, like the # spines for finding bounds self.transDataToAxes = (self.transScale + (self.transLimits + transforms.Affine2D().skew_deg(rot, 0))) # Create the full transform from Data to Pixels self.transData = self.transDataToAxes + self.transAxes # Blended transforms like this need to have the skewing applied using # both axes, in axes coords like before. self._xaxis_transform = (transforms.blended_transform_factory( self.transScale + self.transLimits, transforms.IdentityTransform()) + transforms.Affine2D().skew_deg(rot, 0)) + self.transAxes
Example #25
Source File: test_transforms.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_line_extent_compound_coords2(self): # a simple line in (offset + data) coordinates in the y component, and # in axes coordinates in the x ax = plt.axes() trans = mtransforms.blended_transform_factory(ax.transAxes, mtransforms.Affine2D().scale(10) + ax.transData) ax.plot([0.1, 1.2, 0.8], [35, -5, 18], transform=trans) assert_array_equal(ax.dataLim.get_points(), np.array([[np.inf, -50.], [-np.inf, 350.]])) plt.close()
Example #26
Source File: axis.py From ImageFusion with MIT License | 5 votes |
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
Example #27
Source File: axis.py From CogAlg with MIT License | 5 votes |
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
Example #28
Source File: axis.py From ImageFusion with MIT License | 5 votes |
def _get_offset_text(self): # x in display coords, y in axes coords (to be updated at draw time) offsetText = mtext.Text(x=0, y=0.5, fontproperties=font_manager.FontProperties( size=rcParams['ytick.labelsize']), color=rcParams['ytick.color'], verticalalignment='baseline', horizontalalignment='left', ) offsetText.set_transform(mtransforms.blended_transform_factory( self.axes.transAxes, mtransforms.IdentityTransform())) self._set_artist_props(offsetText) self.offset_text_position = 'left' return offsetText
Example #29
Source File: test_skew.py From ImageFusion with MIT License | 5 votes |
def _set_lim_and_transforms(self): """ This is called once when the plot is created to set up all the transforms for the data, text and grids. """ rot = 30 #Get the standard transform setup from the Axes base class Axes._set_lim_and_transforms(self) # Need to put the skew in the middle, after the scale and limits, # but before the transAxes. This way, the skew is done in Axes # coordinates thus performing the transform around the proper origin # We keep the pre-transAxes transform around for other users, like the # spines for finding bounds self.transDataToAxes = (self.transScale + (self.transLimits + transforms.Affine2D().skew_deg(rot, 0))) # Create the full transform from Data to Pixels self.transData = self.transDataToAxes + self.transAxes # Blended transforms like this need to have the skewing applied using # both axes, in axes coords like before. self._xaxis_transform = (transforms.blended_transform_factory( self.transScale + self.transLimits, transforms.IdentityTransform()) + transforms.Affine2D().skew_deg(rot, 0)) + self.transAxes # Now register the projection with matplotlib so the user can select # it.
Example #30
Source File: spines.py From ImageFusion with MIT License | 5 votes |
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)