X Tutup
Skip to content

wspace is not "The amount of width reserved for blank space between subplots" as documented #6939

@stilley2

Description

@stilley2

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

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)]'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup