Revision: 8167 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8167&view=rev Author: leejjoon Date: 2010-03-02 01:47:54 +0000 (Tue, 02 Mar 2010)
Log Message: ----------- add AxisArtist.invert_ticklabel_direction and fix axis label padding in axes_grid Modified Paths: -------------- trunk/matplotlib/lib/mpl_toolkits/axes_grid/axis_artist.py trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/axis_artist.py =================================================================== --- trunk/matplotlib/lib/mpl_toolkits/axes_grid/axis_artist.py 2010-03-02 01:47:48 UTC (rev 8166) +++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/axis_artist.py 2010-03-02 01:47:54 UTC (rev 8167) @@ -389,6 +389,13 @@ def _get_offset_radius(self): return self._offset_radius + + _get_opposite_direction = {"left":"right", + "right":"left", + "top":"bottom", + "bottom":"top"}.__getitem__ + + def _update(self, renderer): pass @@ -665,6 +672,11 @@ self.set_default_alignment(label_direction) self.set_default_angle(label_direction) + + def invert_axis_direction(self): + label_direction = self._get_opposite_direction(self._axis_direction) + self.set_axis_direction(label_direction) + def _get_ticklabels_offsets(self, renderer, label_direction): """ Calculates the offsets of the ticklabels from the tick and @@ -1021,6 +1033,15 @@ else: self._ticklabel_add_angle = 0 + def invert_ticklabel_direction(self): + self._ticklabel_add_angle = (self._ticklabel_add_angle + 180) % 360 + self.major_ticklabels.invert_axis_direction() + self.minor_ticklabels.invert_axis_direction() + + # def invert_ticks_direction(self): + # self.major_ticks.set_tick_out(not self.major_ticks.get_tick_out()) + # self.minor_ticks.set_tick_out(not self.minor_ticks.get_tick_out()) + def set_axislabel_direction(self, label_direction): """ Adjust the direction of the axislabel. @@ -1190,9 +1211,10 @@ # set extra pad for major and minor ticklabels: # use ticksize of majorticks even for minor ticks. not clear what is best. + dpi_cor = renderer.points_to_pixels(1.) if self.major_ticks.get_visible() and self.major_ticks.get_tick_out(): - self.major_ticklabels._set_external_pad(self.major_ticks._ticksize) - self.minor_ticklabels._set_external_pad(self.major_ticks._ticksize) + self.major_ticklabels._set_external_pad(self.major_ticks._ticksize*dpi_cor) + self.minor_ticklabels._set_external_pad(self.major_ticks._ticksize*dpi_cor) else: self.major_ticklabels._set_external_pad(0) self.minor_ticklabels._set_external_pad(0) @@ -1301,9 +1323,20 @@ #pad_points = self.major_tick_pad - axislabel_pad = max([self.major_ticklabels._axislabel_pad, - self.minor_ticklabels._axislabel_pad]) + #print self._ticklabel_add_angle - self._axislabel_add_angle + #if abs(self._ticklabel_add_angle - self._axislabel_add_angle)%360 > 90: + if self._ticklabel_add_angle != self._axislabel_add_angle: + if (self.major_ticks.get_visible() and not self.major_ticks.get_tick_out()) \ + or \ + (self.minor_ticks.get_visible() and not self.major_ticks.get_tick_out()): + axislabel_pad = self.major_ticks._ticksize + else: + axislabel_pad = 0 + else: + axislabel_pad = max([self.major_ticklabels._axislabel_pad, + self.minor_ticklabels._axislabel_pad]) + #label_offset = axislabel_pad + self.LABELPAD #self.label._set_offset_radius(label_offset) @@ -1341,6 +1374,7 @@ self._draw_line(renderer) + self._draw_ticks(renderer) #self._draw_offsetText(renderer) Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py =================================================================== --- trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py 2010-03-02 01:47:48 UTC (rev 8166) +++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py 2010-03-02 01:47:54 UTC (rev 8167) @@ -336,11 +336,16 @@ get_label_transform() returns a transform of (transAxes+offset) """ loc = self._axis_direction - angle = dict(left=0, - right=0, - bottom=.5*np.pi, - top=.5*np.pi)[loc] + #angle = dict(left=0, + # right=0, + # bottom=.5*np.pi, + # top=.5*np.pi)[loc] + if self.nth_coord == 0: + angle = 0 + else: + angle = 90 + _verts = [0.5, 0.5] fixed_coord = 1-self.nth_coord @@ -369,6 +374,11 @@ else: angle_normal, angle_tangent = 0, 90 + if self.nth_coord == 0: + angle_normal, angle_tangent = 90, 0 + else: + angle_normal, angle_tangent = 0, 90 + #angle = 90 - 90 * self.nth_coord major = self.axis.major This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins