Skip to content

Commit 7de1c1f

Browse files
committed
Increase default titlepad, stop bumping up inner titlepad
1 parent 013ac69 commit 7de1c1f

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

proplot/axes/base.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ def _share_long_axis(self, share, side):
658658
def _update_title_position(self, renderer):
659659
"""
660660
Update the position of proplot inset titles and builtin matplotlib
661-
titles.
661+
titles. This is called by matplotlib at drawtime.
662662
"""
663663
# Custom inset titles
664664
width, height = self.get_size_inches()
@@ -672,20 +672,18 @@ def _update_title_position(self, renderer):
672672
loc = self._abc_loc
673673
if loc in ('left', 'right', 'center'):
674674
continue
675+
pad = rc['axes.titlepad'] / (72 * width)
675676
if loc in ('upper center', 'lower center'):
676677
x = 0.5
677678
elif loc in ('upper left', 'lower left'):
678-
pad = rc['axes.titlepad'] / (72 * width)
679-
x = 1.5 * pad
679+
x = pad
680680
elif loc in ('upper right', 'lower right'):
681-
pad = rc['axes.titlepad'] / (72 * width)
682-
x = 1 - 1.5 * pad
681+
x = 1 - pad
682+
pad = rc['axes.titlepad'] / (72 * height)
683683
if loc in ('upper left', 'upper right', 'upper center'):
684-
pad = rc['axes.titlepad'] / (72 * height)
685-
y = 1 - 1.5 * pad
684+
y = 1 - pad
686685
elif loc in ('lower left', 'lower right', 'lower center'):
687-
pad = rc['axes.titlepad'] / (72 * height)
688-
y = 1.5 * pad
686+
y = pad
689687
obj.set_position((x, y))
690688

691689
# Push title above tick marks, since builtin algorithm used to offset

proplot/figure.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ def _preprocess(self, *args, **kwargs):
7070
# just do the tight layout adjustments and skip resizing.
7171
resize = rc['backend'] != 'nbAgg'
7272

73+
# When re-generating inline figures, the tight layout algorithm can get
74+
# figure size *or* spacing wrong unless we force additional draw! Seems to
75+
# have no adverse effects when calling savefig.
76+
if method == 'print_figure':
77+
self.draw()
78+
7379
# Bail out if we are already pre-processing
7480
# NOTE: The _is_autoresizing check necessary when inserting new gridspec
7581
# rows or columns with the qt backend.

proplot/internals/rcsetup.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
GRIDCOLOR = 'black'
2525
GRIDRATIO = 0.5 # differentiated from major by half size reduction
2626
GRIDSTYLE = '-'
27+
LABELPAD = 4.0 # default is 4.0, previously was 3.0
2728
LABELSIZE = 'medium'
2829
LINEWIDTH = 0.6
2930
MARGIN = 0.05
@@ -34,6 +35,7 @@
3435
TICKMINOR = True
3536
TICKPAD = 2.0
3637
TICKRATIO = 0.8 # very slight width reduction
38+
TITLEPAD = 5.0 # default is 6.0, previously was 3.0
3739
TITLESIZE = 'med-large'
3840
ZLINES = 2 # default zorder for lines
3941
ZPATCHES = 1
@@ -82,11 +84,11 @@
8284
'axes.formatter.use_mathtext': MATHTEXT,
8385
'axes.grid': True, # enable lightweight transparent grid by default
8486
'axes.grid.which': 'major',
85-
'axes.labelpad': 3.0, # more compact
87+
'axes.labelpad': LABELPAD, # more compact
8688
'axes.labelsize': LABELSIZE,
8789
'axes.labelweight': 'normal',
8890
'axes.linewidth': LINEWIDTH,
89-
'axes.titlepad': 3.0, # more compact
91+
'axes.titlepad': TITLEPAD, # more compact
9092
'axes.titlesize': TITLESIZE,
9193
'axes.titleweight': 'normal',
9294
'axes.xmargin': MARGIN,
@@ -850,9 +852,9 @@
850852
'table <title_table>`.'
851853
),
852854
'title.pad': (
853-
3.0,
854-
'Padding between the axes and in arbitrary units. '
855-
'Alias for :rcraw:`axes.titlepad`.'
855+
TITLEPAD,
856+
'Padding between axes and outer titles or a-b-c labels '
857+
'in arbitrary units. Alias for :rcraw:`axes.titlepad`.'
856858
),
857859
'title.size': (
858860
TITLESIZE,

0 commit comments

Comments
 (0)