Esempio n. 1
0
    def set_yspacing(self, spacing):
        '''
        Set the y-axis tick spacing, in degrees. To set the tick spacing to be
        automatically determined, set this to 'auto'.
        '''

        if spacing == 'auto':
            self._ax1.yaxis.apl_auto_tick_spacing = True
            self._ax2.yaxis.apl_auto_tick_spacing = True
        else:
            try:
                au._check_format_spacing_consistency(
                    self._ax1.yaxis.apl_label_form,
                    au.Angle(degrees=spacing, latitude=True))
            except au.InconsistentSpacing:
                warnings.warn(
                    "WARNING: Requested tick spacing format cannot be shown by current label format. The tick spacing will not be changed."
                )
                return
            self._ax1.yaxis.apl_auto_tick_spacing = False
            self._ax2.yaxis.apl_auto_tick_spacing = False
            self._ax1.yaxis.apl_tick_spacing = au.Angle(degrees=spacing,
                                                        latitude=True)
            self._ax2.yaxis.apl_tick_spacing = au.Angle(degrees=spacing,
                                                        latitude=True)

        if hasattr(self._parent, 'grid'):
            self._parent.grid._update()
Esempio n. 2
0
    def __call__(self, x, pos=None):
        "Return the format for tick val x at position pos; pos=None indicated unspecified"

        au._check_format_spacing_consistency(self.axis.apl_label_form, self.axis.apl_tick_spacing)

        hours = "h" in self.axis.apl_label_form

        if self.axis.apl_labels_style == "plain":
            if mpl.rcParams["text.usetex"]:
                label_style = "plain_tex"
            else:
                label_style = "plain_notex"
        else:
            label_style = self.axis.apl_labels_style

        if label_style == "plain_notex":
            sep = (u"\u00b0", u"'", u'"')
            if hours:
                sep = ("h", "m", "s")
        elif label_style == "colons":
            sep = (":", ":", "")
        elif label_style == "plain_tex":
            if hours:
                sep = ("^{h}", "^{m}", "^{s}")
            else:
                sep = ("^{\circ}", "^{\prime}", "^{\prime\prime}")

        ipos = np.argmin(np.abs(self.axis.apl_tick_positions_pix - x))

        label = self.axis.apl_tick_spacing * self.axis.apl_tick_positions_world[ipos]
        if hours:
            label = label.tohours()
        label = label.tostringlist(format=self.axis.apl_label_form, sep=sep)

        if self.coord == x or self.axis.apl_tick_positions_world[ipos] > 0:
            comp_ipos = ipos - 1
        else:
            comp_ipos = ipos + 1

        if comp_ipos >= 0 and comp_ipos <= len(self.axis.apl_tick_positions_pix) - 1:

            comp_label = self.axis.apl_tick_spacing * self.axis.apl_tick_positions_world[comp_ipos]
            if hours:
                comp_label = comp_label.tohours()
            comp_label = comp_label.tostringlist(format=self.axis.apl_label_form, sep=sep)

            for iter in range(len(label)):
                if comp_label[0] == label[0]:
                    label.pop(0)
                    comp_label.pop(0)
                else:
                    break

        if mpl.rcParams["text.usetex"]:
            return "$" + string.join(label, "") + "$"
        else:
            return string.join(label, "")
Esempio n. 3
0
    def __call__(self, x, pos=None):
        'Return the format for tick val x at position pos; pos=None indicated unspecified'

        au._check_format_spacing_consistency(self.axis.apl_label_form, self.axis.apl_tick_spacing)

        hours = 'h' in self.axis.apl_label_form

        if self.axis.apl_labels_style == 'plain':
            if mpl.rcParams['text.usetex']:
                label_style = 'plain_tex'
            else:
                label_style = 'plain_notex'
        else:
            label_style = self.axis.apl_labels_style

        if label_style == 'plain_notex':
            sep = (u'\u00b0', u"'", u'"')
            if hours:
                sep = ('h', 'm', 's')
        elif label_style == 'colons':
            sep = (':', ':', '')
        elif label_style == 'plain_tex':
            if hours:
                sep = ('^{h}', '^{m}', '^{s}')
            else:
                sep = ('^{\circ}', '^{\prime}', '^{\prime\prime}')

        ipos = np.argmin(np.abs(self.axis.apl_tick_positions_pix-x))

        label = self.axis.apl_tick_spacing * self.axis.apl_tick_positions_world[ipos]
        if hours:
            label = label.tohours()
        label = label.tostringlist(format=self.axis.apl_label_form, sep=sep)

        if self.coord == x or self.axis.apl_tick_positions_world[ipos] > 0:
            comp_ipos = ipos - 1
        else:
            comp_ipos = ipos + 1

        if comp_ipos >= 0 and comp_ipos <= len(self.axis.apl_tick_positions_pix)-1:

            comp_label = self.axis.apl_tick_spacing * self.axis.apl_tick_positions_world[comp_ipos]
            if hours:
                comp_label = comp_label.tohours()
            comp_label = comp_label.tostringlist(format=self.axis.apl_label_form, sep=sep)

            for iter in range(len(label)):
                if comp_label[0] == label[0]:
                    label.pop(0)
                    comp_label.pop(0)
                else:
                    break

        if mpl.rcParams['text.usetex']:
            return "$"+string.join(label, "")+"$"
        else:
            return string.join(label, "")
Esempio n. 4
0
    def set_yformat(self, format):
        '''
        Set the format of the y-axis tick labels:

            * ``ddd.ddddd`` - decimal degrees, where the number of decimal places can be varied
            * ``hh`` or ``dd`` - hours (or degrees)
            * ``hh:mm`` or ``dd:mm`` - hours and minutes (or degrees and arcminutes)
            * ``hh:mm:ss`` or ``dd:mm:ss`` - hours, minutes, and seconds (or degrees, arcminutes, and arcseconds)
            * ``hh:mm:ss.ss`` or ``dd:mm:ss.ss`` - hours, minutes, and seconds (or degrees, arcminutes, and arcseconds), where the number of decimal places can be varied.

        If one of these arguments is not specified, the format for that axis is left unchanged.
        '''
        try:
            if not self._ax1.yaxis.apl_auto_tick_spacing:
                au._check_format_spacing_consistency(format, self._ax1.yaxis.apl_tick_spacing)
        except au.InconsistentSpacing:
            warnings.warn("WARNING: Requested label format is not accurate enough to display ticks. The label format will not be changed.")
            return

        self._ax1.yaxis.apl_label_form = format
        self._ax2.yaxis.apl_label_form = format
Esempio n. 5
0
    def set_yspacing(self, spacing):
        '''
        Set the y-axis tick spacing, in degrees. To set the tick spacing to be
        automatically determined, set this to 'auto'.
        '''

        if spacing == 'auto':
            self._ax1.yaxis.apl_auto_tick_spacing = True
            self._ax2.yaxis.apl_auto_tick_spacing = True
        else:
            try:
                au._check_format_spacing_consistency(self._ax1.yaxis.apl_label_form, au.Angle(degrees = spacing, latitude=True))
            except au.InconsistentSpacing:
                warnings.warn("WARNING: Requested tick spacing format cannot be shown by current label format. The tick spacing will not be changed.")
                return
            self._ax1.yaxis.apl_auto_tick_spacing = False
            self._ax2.yaxis.apl_auto_tick_spacing = False
            self._ax1.yaxis.apl_tick_spacing = au.Angle(degrees = spacing, latitude=True)
            self._ax2.yaxis.apl_tick_spacing = au.Angle(degrees = spacing, latitude=True)

        if hasattr(self._parent, 'grid'):
            self._parent.grid._update()
Esempio n. 6
0
    def set_yformat(self, format):
        '''
        Set the format of the y-axis tick labels:

            * ``ddd.ddddd`` - decimal degrees, where the number of decimal places can be varied
            * ``hh`` or ``dd`` - hours (or degrees)
            * ``hh:mm`` or ``dd:mm`` - hours and minutes (or degrees and arcminutes)
            * ``hh:mm:ss`` or ``dd:mm:ss`` - hours, minutes, and seconds (or degrees, arcminutes, and arcseconds)
            * ``hh:mm:ss.ss`` or ``dd:mm:ss.ss`` - hours, minutes, and seconds (or degrees, arcminutes, and arcseconds), where the number of decimal places can be varied.

        If one of these arguments is not specified, the format for that axis is left unchanged.
        '''
        try:
            if not self._ax1.yaxis.apl_auto_tick_spacing:
                au._check_format_spacing_consistency(
                    format, self._ax1.yaxis.apl_tick_spacing)
        except au.InconsistentSpacing:
            warnings.warn(
                "WARNING: Requested label format is not accurate enough to display ticks. The label format will not be changed."
            )
            return

        self._ax1.yaxis.apl_label_form = format
        self._ax2.yaxis.apl_label_form = format
Esempio n. 7
0
    def __call__(self, x, pos=None):
        'Return the format for tick val x at position pos; pos=None indicated unspecified'

        au._check_format_spacing_consistency(self.axis.apl_label_form,
                                             self.axis.apl_tick_spacing)

        hours = 'h' in self.axis.apl_label_form

        if self.axis.apl_labels_style == 'plain':
            if mpl.rcParams['text.usetex']:
                label_style = 'plain_tex'
            else:
                label_style = 'plain_notex'
        else:
            label_style = self.axis.apl_labels_style

        if label_style == 'plain_notex':
            sep = (u'\u00b0', u"'", u'"')
            if hours:
                sep = ('h', 'm', 's')
        elif label_style == 'colons':
            sep = (':', ':', '')
        elif label_style == 'plain_tex':
            if hours:
                sep = ('^{h}', '^{m}', '^{s}')
            else:
                sep = ('^{\circ}', '^{\prime}', '^{\prime\prime}')

        ipos = np.argmin(np.abs(self.axis.apl_tick_positions_pix - x))

        label = self.axis.apl_tick_spacing * self.axis.apl_tick_positions_world[
            ipos]
        if hours:
            label = label.tohours()
        label = label.tostringlist(format=self.axis.apl_label_form, sep=sep)

        if self.coord == x or self.axis.apl_tick_positions_world[ipos] > 0:
            comp_ipos = ipos - 1
        else:
            comp_ipos = ipos + 1

        if comp_ipos >= 0 and comp_ipos <= len(
                self.axis.apl_tick_positions_pix) - 1:

            comp_label = self.axis.apl_tick_spacing * self.axis.apl_tick_positions_world[
                comp_ipos]
            if hours:
                comp_label = comp_label.tohours()
            comp_label = comp_label.tostringlist(
                format=self.axis.apl_label_form, sep=sep)

            for iter in range(len(label)):
                if comp_label[0] == label[0]:
                    label.pop(0)
                    comp_label.pop(0)
                else:
                    break

        if mpl.rcParams['text.usetex']:
            return "$" + string.join(label, "") + "$"
        else:
            return string.join(label, "")