-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Labels
Milestone
Description
If wspace were really the width between the subplots (in normalized figure coordinates) as documented, the first printed value would be 0.2. The second value is to test whether wspace is actually the fraction of a gridspec cell dedicated to whitespace, which is also not the case. The issue seems to be due to the definition of sepW
matplotlib/lib/matplotlib/gridspec.py
Line 116 in f3ed922
| cellW = totWidth/(ncols + wspace*(ncols-1)) |
In order to conform with the documentation, I think sepW should be defined as:
sepW = wspace / (ncols - 1)
but I haven't tested this.
Example code:
from matplotlib import pyplot as plt
gridspec_kwargs = dict(top=0.9, bottom=0.1, left=0.1, right=0.9, wspace=0.2, hspace=0.2)
fig, axs = plt.subplots(nrows=1, ncols=2, gridspec_kw=gridspec_kwargs)
ax1_pos = axs[1].get_position()
ax0_pos = axs[0].get_position()
print('fraction of figure representing space between figures')
print(ax1_pos.x0 - ax0_pos.x1)
print('space between figures represented as a fraction of axis width')
print((ax1_pos.x0 - ax0_pos.x1) / (ax1_pos.x0 - ax0_pos.x0))
Output:
fraction of figure representing space between figures
0.0727272727273
space between figures represented as a fraction of axis width
0.166666666667
Installation information:
matplotlib version: 1.5.1
sys.version output
>>>'3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 2 2016, 17:53:06) \n[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]'
Reactions are currently unavailable