Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7d19bab

Browse files
committed
Fix title placement in polar plots. Remove broken auto layout code.
svn path=/trunk/matplotlib/; revision=5556
1 parent 879c8b9 commit 7d19bab

8 files changed

Lines changed: 4 additions & 111 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,32 +1403,6 @@ def autoscale_view(self, tight=False, scalex=True, scaley=True):
14031403
YL = self.yaxis.get_major_locator().autoscale()
14041404
self.set_ybound(YL)
14051405

1406-
def update_layout(self, renderer):
1407-
pad_pixels = rcParams['xtick.major.pad'] * self.figure.dpi / 72.0
1408-
inverse_transFigure = self.figure.transFigure.inverted()
1409-
t_text, b_text = self.xaxis.get_text_heights(renderer)
1410-
l_text, r_text = self.yaxis.get_text_widths(renderer)
1411-
title_height = self.title.get_window_extent(renderer).height
1412-
title_height += pad_pixels * 2.0
1413-
original_t_text = t_text
1414-
1415-
((l_text, t_text),
1416-
(r_text, b_text),
1417-
(dummy, title_height)) = inverse_transFigure.transform(
1418-
((l_text, t_text),
1419-
(r_text, b_text),
1420-
(0.0, title_height)))
1421-
x0, y0, x1, y1 = self.get_position(True).extents
1422-
# Adjust the title
1423-
self.titleOffsetTrans.clear().translate(
1424-
0, original_t_text + pad_pixels * 2.0)
1425-
1426-
new_position = mtransforms.Bbox.from_extents(
1427-
x0 + l_text, y0 + b_text,
1428-
x1 - r_text, y1 - t_text - title_height)
1429-
1430-
self.set_position(new_position, 'active')
1431-
14321406
#### Drawing
14331407

14341408
def draw(self, renderer=None, inframe=False):
@@ -5654,7 +5628,7 @@ def twiny(self):
56545628
ax2.xaxis.set_label_position('top')
56555629
self.xaxis.tick_bottom()
56565630
return ax2
5657-
5631+
56585632
def get_shared_x_axes(self):
56595633
'Return a copy of the shared axes Grouper object for x axes'
56605634
return self._shared_x_axes

lib/matplotlib/config/mplconfig.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ class figure(TConfig):
238238
dpi = T.Float(80)
239239
facecolor = T.Trait('0.75', mplT.ColorHandler())
240240
edgecolor = T.Trait('white', mplT.ColorHandler())
241-
autolayout = T.false
242241

243242
class subplot(TConfig):
244243
"""The figure subplot parameters. All dimensions are fraction
@@ -408,7 +407,6 @@ def __init__(self, tconfig):
408407
'figure.dpi' : (self.tconfig.figure, 'dpi'),
409408
'figure.facecolor' : (self.tconfig.figure, 'facecolor'),
410409
'figure.edgecolor' : (self.tconfig.figure, 'edgecolor'),
411-
'figure.autolayout' : (self.tconfig.figure, 'autolayout'),
412410

413411
'figure.subplot.left' : (self.tconfig.figure.subplot, 'left'),
414412
'figure.subplot.right' : (self.tconfig.figure.subplot, 'right'),

lib/matplotlib/config/rcsetup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,6 @@ def __call__(self, s):
439439
'figure.dpi' : [80, validate_float], # DPI
440440
'figure.facecolor' : ['0.75', validate_color], # facecolor; scalar gray
441441
'figure.edgecolor' : ['w', validate_color], # edgecolor; white
442-
'figure.autolayout' : [False, validate_bool],
443442

444443
'figure.subplot.left' : [0.125, ValidateInterval(0, 1, closedmin=False, closedmax=False)],
445444
'figure.subplot.right' : [0.9, ValidateInterval(0, 1, closedmin=False, closedmax=False)],

lib/matplotlib/figure.py

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ def __init__(self,
240240
self.clf()
241241

242242
self._cachedRenderer = None
243-
self._autoLayout = rcParams['figure.autolayout']
244243

245244
def _get_dpi(self):
246245
return self._dpi
@@ -250,9 +249,6 @@ def _set_dpi(self, dpi):
250249
self.callbacks.process('dpi_changed', self)
251250
dpi = property(_get_dpi, _set_dpi)
252251

253-
def enable_auto_layout(self, setting=True):
254-
self._autoLayout = setting
255-
256252
def autofmt_xdate(self, bottom=0.2, rotation=30, ha='right'):
257253
"""
258254
Date ticklabels often overlap, so it is useful to rotate them
@@ -284,7 +280,7 @@ def autofmt_xdate(self, bottom=0.2, rotation=30, ha='right'):
284280
label.set_visible(False)
285281
ax.set_xlabel('')
286282

287-
if allsubplots and not self._autoLayout:
283+
if allsubplots:
288284
self.subplots_adjust(bottom=bottom)
289285

290286
def get_children(self):
@@ -765,62 +761,6 @@ def draw(self, renderer):
765761
renderer.draw_image(l, b, im, self.bbox,
766762
*self.get_transformed_clip_path_and_affine())
767763

768-
# update the positions of the axes
769-
# This gives each of the axes the opportunity to resize itself
770-
# based on the tick and axis labels etc., and then makes sure
771-
# that any axes that began life aligned to another axes remains
772-
# aligned after these adjustments
773-
if self._autoLayout and len(self.axes) > 1:
774-
aligned_positions = [{}, {}, {}, {}]
775-
sizes = [{}, {}]
776-
for a in self.axes:
777-
a.update_layout(renderer)
778-
orig_pos = a.get_position(True)
779-
curr_pos = a.get_position()
780-
for pos, orig, curr in zip(aligned_positions,
781-
orig_pos.get_points().flatten(),
782-
curr_pos.get_points().flatten()):
783-
if orig in pos:
784-
pos[orig][0].append(a)
785-
pos[orig][1].add(curr)
786-
else:
787-
pos[orig] = [[a], set([curr])]
788-
for size, orig, curr in zip(sizes,
789-
orig_pos.size,
790-
curr_pos.size):
791-
orig = round(orig * 1000.0) / 1000.0
792-
if orig in size:
793-
size[orig][0].append(a)
794-
size[orig][1].add(curr)
795-
else:
796-
size[orig] = [[a], set([curr])]
797-
798-
for i, pos in enumerate(aligned_positions):
799-
for axes, places in pos.values():
800-
if len(places) > 1:
801-
if i < 2:
802-
curr = max(places)
803-
else:
804-
curr = min(places)
805-
for a in axes:
806-
curr_pos = a.get_position().frozen()
807-
curr_pos.get_points()[i/2, i%2] = curr
808-
a.set_position(curr_pos, 'active')
809-
810-
for i, size in enumerate(sizes):
811-
for axes, dims in size.values():
812-
new = min(dims)
813-
for a in axes:
814-
curr_pos = a.get_position().frozen()
815-
curr = curr_pos.size[i]
816-
if curr > new:
817-
extra = (curr - new) * 0.5
818-
curr_pos.get_points()[0, i] += extra
819-
curr_pos.get_points()[1, i] -= extra
820-
a.set_position(curr_pos, 'active')
821-
elif self._autoLayout:
822-
for a in self.axes: a.update_layout(renderer)
823-
824764
# render the axes
825765
for a in self.axes: a.draw(renderer)
826766

lib/matplotlib/projections/geo.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,6 @@ def _get_affine_transform(self):
109109
.scale(0.5 / xscale, 0.5 / yscale) \
110110
.translate(0.5, 0.5)
111111

112-
def update_layout(self, renderer):
113-
t_text, b_text = self.xaxis.get_text_heights(renderer)
114-
l_text, r_text = self.yaxis.get_text_widths(renderer)
115-
originalPosition = self.get_position(True)
116-
title_offset = (b_text - originalPosition.transformed(
117-
self.figure.transFigure).height) / 2.0
118-
self.titleOffsetTrans.clear().translate(0, title_offset)
119-
120112
def get_xaxis_transform(self):
121113
return self._xaxis_transform
122114

lib/matplotlib/projections/polar.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ def __init__(self, *args, **kwargs):
176176
def cla(self):
177177
Axes.cla(self)
178178

179+
self.title.set_y(1.05)
180+
179181
self.xaxis.set_major_formatter(self.ThetaFormatter())
180182
angles = npy.arange(0.0, 360.0, 45.0)
181183
self.set_thetagrids(angles)
@@ -241,14 +243,6 @@ def _set_lim_and_transforms(self):
241243
self._yaxis_transform
242244
)
243245

244-
def update_layout(self, renderer):
245-
t_text, b_text = self.xaxis.get_text_heights(renderer)
246-
l_text, r_text = self.yaxis.get_text_widths(renderer)
247-
originalPosition = self.get_position(True)
248-
title_offset = (b_text - originalPosition.transformed(
249-
self.figure.transFigure).height) / 2.0
250-
self.titleOffsetTrans.clear().translate(0, title_offset)
251-
252246
def get_xaxis_transform(self):
253247
return self._xaxis_transform
254248

lib/matplotlib/rcsetup.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,6 @@ def __call__(self, s):
457457
'figure.subplot.wspace' : [0.2, ValidateInterval(0, 1, closedmin=True, closedmax=False)],
458458
'figure.subplot.hspace' : [0.2, ValidateInterval(0, 1, closedmin=True, closedmax=False)],
459459

460-
'figure.autolayout' : [False, validate_bool],
461-
462460
'savefig.dpi' : [100, validate_float], # DPI
463461
'savefig.facecolor' : ['w', validate_color], # facecolor; white
464462
'savefig.edgecolor' : ['w', validate_color], # edgecolor; white

matplotlibrc.template

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,6 @@ numerix : %(numerix)s # numpy, Numeric or numarray
249249
#figure.subplot.wspace : 0.2 # the amount of width reserved for blank space between subplots
250250
#figure.subplot.hspace : 0.2 # the amount of height reserved for white space between subplots
251251

252-
#figure.autolayout : False # when True, adjust the axes so that text doesn't overlap
253-
254252
### IMAGES
255253
#image.aspect : equal # equal | auto | a number
256254
#image.interpolation : bilinear # see help(imshow) for options

0 commit comments

Comments
 (0)