Python matplotlib.transforms.ScaledTranslation() Examples
The following are 30
code examples of matplotlib.transforms.ScaledTranslation().
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: _base.py From neural-network-animation with MIT License | 6 votes |
def get_yaxis_text2_transform(self, pad_points): """ Get the transformation used for drawing the secondary y-axis labels, which will add the given amount of padding (in points) between the axes and the label. The x-direction is in axis coordinates and the y-direction is in data coordinates. Returns a 3-tuple of the form:: (transform, valign, halign) where *valign* and *halign* are requested alignments for the text. .. note:: This transformation is primarily used by the :class:`~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ return (self.get_yaxis_transform(which='tick2') + mtransforms.ScaledTranslation(pad_points / 72.0, 0, self.figure.dpi_scale_trans), "center", "left")
Example #2
Source File: polar.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def get_matrix(self): if self._invalid: if self.mode == 'rlabel': angle = ( np.deg2rad(self.axes.get_rlabel_position()) * self.axes.get_theta_direction() + self.axes.get_theta_offset() ) else: if self.mode == 'min': angle = self.axes._realViewLim.xmin elif self.mode == 'max': angle = self.axes._realViewLim.xmax if self.mode in ('rlabel', 'min'): padx = np.cos(angle - np.pi / 2) pady = np.sin(angle - np.pi / 2) else: padx = np.cos(angle + np.pi / 2) pady = np.sin(angle + np.pi / 2) self._t = (self.pad * padx / 72, self.pad * pady / 72) return mtransforms.ScaledTranslation.get_matrix(self)
Example #3
Source File: _base.py From CogAlg with MIT License | 6 votes |
def get_xaxis_text2_transform(self, pad_points): """ Returns ------- transform : Transform The transform used for drawing secondary x-axis labels, which will add *pad_points* of padding (in points) between the axes and the label. The x-direction is in data coordinates and the y-direction is in axis corrdinates valign : {'center', 'top', 'bottom', 'baseline', 'center_baseline'} The text vertical alignment. halign : {'center', 'left', 'right'} The text horizontal alignment. Notes ----- This transformation is primarily used by the `~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ labels_align = rcParams["xtick.alignment"] return (self.get_xaxis_transform(which='tick2') + mtransforms.ScaledTranslation(0, pad_points / 72, self.figure.dpi_scale_trans), "bottom", labels_align)
Example #4
Source File: _base.py From CogAlg with MIT License | 6 votes |
def get_yaxis_text2_transform(self, pad_points): """ Returns ------- transform : Transform The transform used for drawing secondart y-axis labels, which will add *pad_points* of padding (in points) between the axes and the label. The x-direction is in axis coordinates and the y-direction is in data corrdinates valign : {'center', 'top', 'bottom', 'baseline', 'center_baseline'} The text vertical alignment. halign : {'center', 'left', 'right'} The text horizontal alignment. Notes ----- This transformation is primarily used by the `~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ labels_align = rcParams["ytick.alignment"] return (self.get_yaxis_transform(which='tick2') + mtransforms.ScaledTranslation(pad_points / 72, 0, self.figure.dpi_scale_trans), labels_align, "left")
Example #5
Source File: _base.py From ImageFusion with MIT License | 6 votes |
def get_xaxis_text1_transform(self, pad_points): """ Get the transformation used for drawing x-axis labels, which will add the given amount of padding (in points) between the axes and the label. The x-direction is in data coordinates and the y-direction is in axis coordinates. Returns a 3-tuple of the form:: (transform, valign, halign) where *valign* and *halign* are requested alignments for the text. .. note:: This transformation is primarily used by the :class:`~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ return (self.get_xaxis_transform(which='tick1') + mtransforms.ScaledTranslation(0, -1 * pad_points / 72.0, self.figure.dpi_scale_trans), "top", "center")
Example #6
Source File: _base.py From ImageFusion with MIT License | 6 votes |
def get_xaxis_text2_transform(self, pad_points): """ Get the transformation used for drawing the secondary x-axis labels, which will add the given amount of padding (in points) between the axes and the label. The x-direction is in data coordinates and the y-direction is in axis coordinates. Returns a 3-tuple of the form:: (transform, valign, halign) where *valign* and *halign* are requested alignments for the text. .. note:: This transformation is primarily used by the :class:`~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ return (self.get_xaxis_transform(which='tick2') + mtransforms.ScaledTranslation(0, pad_points / 72.0, self.figure.dpi_scale_trans), "bottom", "center")
Example #7
Source File: _base.py From ImageFusion with MIT License | 6 votes |
def get_yaxis_text1_transform(self, pad_points): """ Get the transformation used for drawing y-axis labels, which will add the given amount of padding (in points) between the axes and the label. The x-direction is in axis coordinates and the y-direction is in data coordinates. Returns a 3-tuple of the form:: (transform, valign, halign) where *valign* and *halign* are requested alignments for the text. .. note:: This transformation is primarily used by the :class:`~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ return (self.get_yaxis_transform(which='tick1') + mtransforms.ScaledTranslation(-1 * pad_points / 72.0, 0, self.figure.dpi_scale_trans), "center", "right")
Example #8
Source File: _base.py From ImageFusion with MIT License | 6 votes |
def get_yaxis_text2_transform(self, pad_points): """ Get the transformation used for drawing the secondary y-axis labels, which will add the given amount of padding (in points) between the axes and the label. The x-direction is in axis coordinates and the y-direction is in data coordinates. Returns a 3-tuple of the form:: (transform, valign, halign) where *valign* and *halign* are requested alignments for the text. .. note:: This transformation is primarily used by the :class:`~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ return (self.get_yaxis_transform(which='tick2') + mtransforms.ScaledTranslation(pad_points / 72.0, 0, self.figure.dpi_scale_trans), "center", "left")
Example #9
Source File: polar.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def get_matrix(self): if self._invalid: if self.mode == 'rlabel': angle = ( np.deg2rad(self.axes.get_rlabel_position()) * self.axes.get_theta_direction() + self.axes.get_theta_offset() ) else: if self.mode == 'min': angle = self.axes._realViewLim.xmin elif self.mode == 'max': angle = self.axes._realViewLim.xmax if self.mode in ('rlabel', 'min'): padx = np.cos(angle - np.pi / 2) pady = np.sin(angle - np.pi / 2) else: padx = np.cos(angle + np.pi / 2) pady = np.sin(angle + np.pi / 2) self._t = (self.pad * padx / 72, self.pad * pady / 72) return mtransforms.ScaledTranslation.get_matrix(self)
Example #10
Source File: polar.py From twitter-stock-recommendation with MIT License | 6 votes |
def get_matrix(self): if self._invalid: if self.mode == 'rlabel': angle = ( np.deg2rad(self.axes.get_rlabel_position()) * self.axes.get_theta_direction() + self.axes.get_theta_offset() ) else: if self.mode == 'min': angle = self.axes._realViewLim.xmin elif self.mode == 'max': angle = self.axes._realViewLim.xmax if self.mode in ('rlabel', 'min'): padx = np.cos(angle - np.pi / 2) pady = np.sin(angle - np.pi / 2) else: padx = np.cos(angle + np.pi / 2) pady = np.sin(angle + np.pi / 2) self._t = (self.pad * padx / 72, self.pad * pady / 72) return mtransforms.ScaledTranslation.get_matrix(self)
Example #11
Source File: _base.py From CogAlg with MIT License | 6 votes |
def get_xaxis_text1_transform(self, pad_points): """ Returns ------- transform : Transform The transform used for drawing x-axis labels, which will add *pad_points* of padding (in points) between the axes and the label. The x-direction is in data coordinates and the y-direction is in axis corrdinates valign : {'center', 'top', 'bottom', 'baseline', 'center_baseline'} The text vertical alignment. halign : {'center', 'left', 'right'} The text horizontal alignment. Notes ----- This transformation is primarily used by the `~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ labels_align = rcParams["xtick.alignment"] return (self.get_xaxis_transform(which='tick1') + mtransforms.ScaledTranslation(0, -1 * pad_points / 72, self.figure.dpi_scale_trans), "top", labels_align)
Example #12
Source File: _base.py From neural-network-animation with MIT License | 6 votes |
def get_yaxis_text1_transform(self, pad_points): """ Get the transformation used for drawing y-axis labels, which will add the given amount of padding (in points) between the axes and the label. The x-direction is in axis coordinates and the y-direction is in data coordinates. Returns a 3-tuple of the form:: (transform, valign, halign) where *valign* and *halign* are requested alignments for the text. .. note:: This transformation is primarily used by the :class:`~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ return (self.get_yaxis_transform(which='tick1') + mtransforms.ScaledTranslation(-1 * pad_points / 72.0, 0, self.figure.dpi_scale_trans), "center", "right")
Example #13
Source File: _base.py From neural-network-animation with MIT License | 6 votes |
def get_xaxis_text2_transform(self, pad_points): """ Get the transformation used for drawing the secondary x-axis labels, which will add the given amount of padding (in points) between the axes and the label. The x-direction is in data coordinates and the y-direction is in axis coordinates. Returns a 3-tuple of the form:: (transform, valign, halign) where *valign* and *halign* are requested alignments for the text. .. note:: This transformation is primarily used by the :class:`~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ return (self.get_xaxis_transform(which='tick2') + mtransforms.ScaledTranslation(0, pad_points / 72.0, self.figure.dpi_scale_trans), "bottom", "center")
Example #14
Source File: _base.py From neural-network-animation with MIT License | 6 votes |
def get_xaxis_text1_transform(self, pad_points): """ Get the transformation used for drawing x-axis labels, which will add the given amount of padding (in points) between the axes and the label. The x-direction is in data coordinates and the y-direction is in axis coordinates. Returns a 3-tuple of the form:: (transform, valign, halign) where *valign* and *halign* are requested alignments for the text. .. note:: This transformation is primarily used by the :class:`~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ return (self.get_xaxis_transform(which='tick1') + mtransforms.ScaledTranslation(0, -1 * pad_points / 72.0, self.figure.dpi_scale_trans), "top", "center")
Example #15
Source File: polar.py From CogAlg with MIT License | 6 votes |
def get_matrix(self): if self._invalid: if self.mode == 'rlabel': angle = ( np.deg2rad(self.axes.get_rlabel_position()) * self.axes.get_theta_direction() + self.axes.get_theta_offset() ) else: if self.mode == 'min': angle = self.axes._realViewLim.xmin elif self.mode == 'max': angle = self.axes._realViewLim.xmax if self.mode in ('rlabel', 'min'): padx = np.cos(angle - np.pi / 2) pady = np.sin(angle - np.pi / 2) else: padx = np.cos(angle + np.pi / 2) pady = np.sin(angle + np.pi / 2) self._t = (self.pad * padx / 72, self.pad * pady / 72) return mtransforms.ScaledTranslation.get_matrix(self)
Example #16
Source File: polar.py From coffeegrindsize with MIT License | 6 votes |
def get_matrix(self): if self._invalid: if self.mode == 'rlabel': angle = ( np.deg2rad(self.axes.get_rlabel_position()) * self.axes.get_theta_direction() + self.axes.get_theta_offset() ) else: if self.mode == 'min': angle = self.axes._realViewLim.xmin elif self.mode == 'max': angle = self.axes._realViewLim.xmax if self.mode in ('rlabel', 'min'): padx = np.cos(angle - np.pi / 2) pady = np.sin(angle - np.pi / 2) else: padx = np.cos(angle + np.pi / 2) pady = np.sin(angle + np.pi / 2) self._t = (self.pad * padx / 72, self.pad * pady / 72) return mtransforms.ScaledTranslation.get_matrix(self)
Example #17
Source File: _base.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def get_yaxis_text2_transform(self, pad_points): """ Returns ------- transform : Transform The transform used for drawing secondart y-axis labels, which will add *pad_points* of padding (in points) between the axes and the label. The x-direction is in axis coordinates and the y-direction is in data corrdinates valign : {'center', 'top', 'bottom', 'baseline', 'center_baseline'} The text vertical alignment. halign : {'center', 'left', 'right'} The text horizontal alignment. Notes ----- This transformation is primarily used by the `~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ labels_align = rcParams["ytick.alignment"] return (self.get_yaxis_transform(which='tick2') + mtransforms.ScaledTranslation(pad_points / 72, 0, self.figure.dpi_scale_trans), labels_align, "left")
Example #18
Source File: _base.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def get_xaxis_text2_transform(self, pad_points): """ Returns ------- transform : Transform The transform used for drawing secondary x-axis labels, which will add *pad_points* of padding (in points) between the axes and the label. The x-direction is in data coordinates and the y-direction is in axis corrdinates valign : {'center', 'top', 'bottom', 'baseline', 'center_baseline'} The text vertical alignment. halign : {'center', 'left', 'right'} The text horizontal alignment. Notes ----- This transformation is primarily used by the `~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ labels_align = rcParams["xtick.alignment"] return (self.get_xaxis_transform(which='tick2') + mtransforms.ScaledTranslation(0, pad_points / 72, self.figure.dpi_scale_trans), "bottom", labels_align)
Example #19
Source File: _base.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def get_xaxis_text1_transform(self, pad_points): """ Returns ------- transform : Transform The transform used for drawing x-axis labels, which will add *pad_points* of padding (in points) between the axes and the label. The x-direction is in data coordinates and the y-direction is in axis corrdinates valign : {'center', 'top', 'bottom', 'baseline', 'center_baseline'} The text vertical alignment. halign : {'center', 'left', 'right'} The text horizontal alignment. Notes ----- This transformation is primarily used by the `~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ labels_align = rcParams["xtick.alignment"] return (self.get_xaxis_transform(which='tick1') + mtransforms.ScaledTranslation(0, -1 * pad_points / 72, self.figure.dpi_scale_trans), "top", labels_align)
Example #20
Source File: polar.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def get_matrix(self): if self._invalid: if self.mode == 'rlabel': angle = ( np.deg2rad(self.axes.get_rlabel_position()) * self.axes.get_theta_direction() + self.axes.get_theta_offset() ) else: if self.mode == 'min': angle = self.axes._realViewLim.xmin elif self.mode == 'max': angle = self.axes._realViewLim.xmax if self.mode in ('rlabel', 'min'): padx = np.cos(angle - np.pi / 2) pady = np.sin(angle - np.pi / 2) else: padx = np.cos(angle + np.pi / 2) pady = np.sin(angle + np.pi / 2) self._t = (self.pad * padx / 72, self.pad * pady / 72) return mtransforms.ScaledTranslation.get_matrix(self)
Example #21
Source File: ep_canvas.py From catplot with MIT License | 6 votes |
def _render_ep_lines(self): """ Render energy profile lines in canvas. """ for line in self.lines: for idx in range(line.shadow_depth): identity_trans = transforms.IdentityTransform() offset = transforms.ScaledTranslation(idx, -idx, identity_trans) shadow_trans = self.axes.transData + offset # Create matplotlib Line2D. alpha = (line.shadow_depth-idx)/2.0/line.shadow_depth shadow_line = Line2D(line.x, line.y, linewidth=line.line_width, color=line.shadow_color, transform=shadow_trans, alpha=alpha) self.shadow_lines.append(shadow_line)
Example #22
Source File: _base.py From coffeegrindsize with MIT License | 5 votes |
def _set_title_offset_trans(self, title_offset_points): """ Set the offset for the title either from rcParams['axes.titlepad'] or from set_title kwarg ``pad``. """ self.titleOffsetTrans = mtransforms.ScaledTranslation( 0.0, title_offset_points / 72, self.figure.dpi_scale_trans) for _title in (self.title, self._left_title, self._right_title): _title.set_transform(self.transAxes + self.titleOffsetTrans) _title.set_clip_box(None)
Example #23
Source File: pointartist.py From compas with MIT License | 5 votes |
def _T(self): F = self.plotter.figure.dpi_scale_trans S = ScaledTranslation(self.point[0], self.point[1], self.plotter.axes.transData) T = F + S return T
Example #24
Source File: _base.py From coffeegrindsize with MIT License | 5 votes |
def get_yaxis_text2_transform(self, pad_points): """ Get the transformation used for drawing the secondary y-axis labels, which will add the given amount of padding (in points) between the axes and the label. The x-direction is in axis coordinates and the y-direction is in data coordinates. Returns a 3-tuple of the form:: (transform, valign, halign) where *valign* and *halign* are requested alignments for the text. .. note:: This transformation is primarily used by the :class:`~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ labels_align = matplotlib.rcParams["ytick.alignment"] return (self.get_yaxis_transform(which='tick2') + mtransforms.ScaledTranslation(pad_points / 72, 0, self.figure.dpi_scale_trans), labels_align, "left")
Example #25
Source File: _base.py From coffeegrindsize with MIT License | 5 votes |
def get_xaxis_text2_transform(self, pad_points): """ Get the transformation used for drawing the secondary x-axis labels, which will add the given amount of padding (in points) between the axes and the label. The x-direction is in data coordinates and the y-direction is in axis coordinates. Returns a 3-tuple of the form:: (transform, valign, halign) where *valign* and *halign* are requested alignments for the text. .. note:: This transformation is primarily used by the :class:`~matplotlib.axis.Axis` class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations. """ labels_align = matplotlib.rcParams["xtick.alignment"] return (self.get_xaxis_transform(which='tick2') + mtransforms.ScaledTranslation(0, pad_points / 72, self.figure.dpi_scale_trans), "bottom", labels_align)
Example #26
Source File: polar.py From CogAlg with MIT License | 5 votes |
def __init__(self, axes, *args, **kwargs): self._text1_translate = mtransforms.ScaledTranslation( 0, 0, axes.figure.dpi_scale_trans) self._text2_translate = mtransforms.ScaledTranslation( 0, 0, axes.figure.dpi_scale_trans) super().__init__(axes, *args, **kwargs)
Example #27
Source File: polar.py From CogAlg with MIT License | 5 votes |
def __init__(self, axes, pad, mode): mtransforms.ScaledTranslation.__init__(self, pad, pad, axes.figure.dpi_scale_trans) self.set_children(axes._realViewLim) self.axes = axes self.mode = mode self.pad = pad
Example #28
Source File: _base.py From CogAlg with MIT License | 5 votes |
def _set_title_offset_trans(self, title_offset_points): """ Set the offset for the title either from rcParams['axes.titlepad'] or from set_title kwarg ``pad``. """ self.titleOffsetTrans = mtransforms.ScaledTranslation( 0.0, title_offset_points / 72, self.figure.dpi_scale_trans) for _title in (self.title, self._left_title, self._right_title): _title.set_transform(self.transAxes + self.titleOffsetTrans) _title.set_clip_box(None)
Example #29
Source File: _base.py From twitter-stock-recommendation with MIT License | 5 votes |
def _set_title_offset_trans(self, title_offset_points): """ Set the offset for the title either from rcParams['axes.titlepad'] or from set_title kwarg ``pad``. """ self.titleOffsetTrans = mtransforms.ScaledTranslation( 0.0, title_offset_points / 72.0, self.figure.dpi_scale_trans) for _title in (self.title, self._left_title, self._right_title): _title.set_transform(self.transAxes + self.titleOffsetTrans) _title.set_clip_box(None)
Example #30
Source File: polar.py From twitter-stock-recommendation with MIT License | 5 votes |
def __init__(self, axes, *args, **kwargs): self._text1_translate = mtransforms.ScaledTranslation( 0, 0, axes.figure.dpi_scale_trans) self._text2_translate = mtransforms.ScaledTranslation( 0, 0, axes.figure.dpi_scale_trans) super(ThetaTick, self).__init__(axes, *args, **kwargs)