diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index 83c5e5a43a4a..14ce5a4c0dc2 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -300,16 +300,26 @@ def _apply_params(self, **kw): switches = [k for k in kw if k in switchkw] for k in switches: setattr(self, k, kw.pop(k)) - dirpad = [k for k in kw if k in ['pad', 'tickdir']] - if dirpad: + newmarker = [k for k in kw if k in ['size', 'width', 'pad', 'tickdir']] + if newmarker: + self._size = kw.pop('size', self._size) + # Width could be handled outside this block, but it is + # convenient to leave it here. + self._width = kw.pop('width', self._width) self._base_pad = kw.pop('pad', self._base_pad) + # apply_tickdir uses _size and _base_pad to make _pad, + # and also makes _tickmarkers. self.apply_tickdir(kw.pop('tickdir', self._tickdir)) + self.tick1line.set_marker(self._tickmarkers[0]) + self.tick2line.set_marker(self._tickmarkers[1]) + for line in (self.tick1line, self.tick2line): + line.set_markersize(self._size) + line.set_markeredgewidth(self._width) + # _get_text1_transform uses _pad from apply_tickdir. trans = self._get_text1_transform()[0] self.label1.set_transform(trans) trans = self._get_text2_transform()[0] self.label2.set_transform(trans) - self.tick1line.set_marker(self._tickmarkers[0]) - self.tick2line.set_marker(self._tickmarkers[1]) tick_kw = dict([kv for kv in six.iteritems(kw) if kv[0] in ['color', 'zorder']]) if tick_kw: @@ -317,16 +327,6 @@ def _apply_params(self, **kw): self.tick2line.set(**tick_kw) for k, v in six.iteritems(tick_kw): setattr(self, '_' + k, v) - tick_list = [kv for kv - in six.iteritems(kw) if kv[0] in ['size', 'width']] - for k, v in tick_list: - setattr(self, '_' + k, v) - if k == 'size': - self.tick1line.set_markersize(v) - self.tick2line.set_markersize(v) - else: - self.tick1line.set_markeredgewidth(v) - self.tick2line.set_markeredgewidth(v) label_list = [k for k in six.iteritems(kw) if k[0] in ['labelsize', 'labelcolor']] if label_list: diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/outward_ticks.pdf b/lib/matplotlib/tests/baseline_images/test_tightlayout/outward_ticks.pdf index 7e0dd1ebcb58..664c30a7b78e 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/outward_ticks.pdf and b/lib/matplotlib/tests/baseline_images/test_tightlayout/outward_ticks.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/outward_ticks.png b/lib/matplotlib/tests/baseline_images/test_tightlayout/outward_ticks.png index cc73be432858..c34dc0bb9403 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_tightlayout/outward_ticks.png and b/lib/matplotlib/tests/baseline_images/test_tightlayout/outward_ticks.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_tightlayout/outward_ticks.svg b/lib/matplotlib/tests/baseline_images/test_tightlayout/outward_ticks.svg index 806cfe13c22b..39c20581360b 100644 --- a/lib/matplotlib/tests/baseline_images/test_tightlayout/outward_ticks.svg +++ b/lib/matplotlib/tests/baseline_images/test_tightlayout/outward_ticks.svg @@ -19,31 +19,31 @@ z - - - - - @@ -52,80 +52,282 @@ L 255.543437 41.76 +" id="mf69f7a8a7a" style="stroke:#000000;stroke-width:3;"/> - + +" id="m96682210b5" style="stroke:#000000;stroke-width:3;"/> - + + + + + + + + + + + + + - + - + + + + + + + + + + + + - + - + + + + + + + + + + + + - + - + + + + + + + + + + + + - + - + + + + + + + + + + + + - + - + + + + + + + + + + + + @@ -134,20 +336,20 @@ L 0 -16 +" id="mee62a85f81" style="stroke:#000000;stroke-width:3;"/> - + +" id="md353597a36" style="stroke:#000000;stroke-width:3;"/> - + @@ -158,80 +360,128 @@ L 0 -32 +" id="m5e8c5626a5" style="stroke:#000000;stroke-width:3;"/> - + +" id="mff051dedeb" style="stroke:#000000;stroke-width:3;"/> - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + @@ -240,20 +490,20 @@ L 16 0 +" id="m6278d38ce8" style="stroke:#000000;stroke-width:3;"/> - + +" id="md7f24aef58" style="stroke:#000000;stroke-width:3;"/> - + @@ -261,30 +511,30 @@ L 32 0 - - - - - @@ -292,72 +542,120 @@ L 534.24 41.76 - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + @@ -366,72 +664,120 @@ L 534.24 41.76 - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + @@ -439,31 +785,31 @@ L 534.24 41.76 - - - - - @@ -472,75 +818,123 @@ L 255.543437 244.540156 +" id="ma8604b1bb1" style="stroke:#000000;stroke-width:3;"/> - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + @@ -551,75 +945,123 @@ L 0 -16 +" id="m500fcd8693" style="stroke:#000000;stroke-width:3;"/> - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + @@ -627,103 +1069,151 @@ L -16 -0 - - - - - - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + @@ -732,72 +1222,120 @@ L 534.24 244.540156 - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + - + - + + + + + + + + + diff --git a/lib/matplotlib/tests/test_tightlayout.py b/lib/matplotlib/tests/test_tightlayout.py index b3b3a9647afc..a60a94210967 100644 --- a/lib/matplotlib/tests/test_tightlayout.py +++ b/lib/matplotlib/tests/test_tightlayout.py @@ -159,7 +159,8 @@ def test_tight_layout8(): example_plot(ax, fontsize=24) -@image_comparison(baseline_images=['outward_ticks'], remove_text=True) +# The following test is misleading when the text is removed. +@image_comparison(baseline_images=['outward_ticks'], remove_text=False) def test_outward_ticks(): 'Test automatic use of tight_layout' fig = plt.figure() @@ -170,6 +171,8 @@ def test_outward_ticks(): tickdir='out', length=32, width=3, tick1On=True, which='minor') ax.yaxis.set_tick_params( tickdir='out', length=32, width=3, tick1On=True, which='minor') + # The following minor ticks are not labelled, and they + # are drawn over the major ticks and labels--ugly! ax.xaxis.set_ticks([0], minor=True) ax.yaxis.set_ticks([0], minor=True) ax = fig.add_subplot(222)