Commit e35ab939 authored by Gregory Ashton's avatar Gregory Ashton

Minor polishing of figure dimensions

parent c7830615
......@@ -47,8 +47,24 @@ def idx_array_slice(D, axis, slice_idx):
return res
def _get_fig_and_axes(ndim, factor, whspace):
lbdim = 0.5 * factor # size of left/bottom margin
trdim = 0.2 * factor # size of top/right margin
plotdim = factor * ndim + factor * (ndim - 1.) * whspace
dim = lbdim + plotdim + trdim
fig, axes = plt.subplots(ndim, ndim, figsize=(dim, dim))
# Format the figure.
lb = lbdim / dim
tr = (lbdim + plotdim) / dim
fig.subplots_adjust(left=lb, bottom=lb, right=0.98*tr, top=tr,
wspace=whspace, hspace=whspace)
return fig, axes
def gridcorner(D, xyz, labels=None, projection='max_slice', max_n_ticks=4,
factor=3, whspace=0.05, showDvals=True, lines=None, **kwargs):
factor=2, whspace=0.05, showDvals=True, lines=None,
label_offset=0.4, **kwargs):
""" Generate a grid corner plot
Parameters
......@@ -84,11 +100,9 @@ def gridcorner(D, xyz, labels=None, projection='max_slice', max_n_ticks=4,
The figure and NxN set of axes
"""
ndim = D.ndim
lbdim = 0.4 * factor # size of left/bottom margin
trdim = 0.2 * factor # size of top/right margin
plotdim = factor * ndim + factor * (ndim - 1.) * whspace
dim = lbdim + plotdim + trdim
fig, axes = _get_fig_and_axes(ndim, factor, whspace)
if type(projection) == str:
if projection in ['log_mean']:
......@@ -98,13 +112,6 @@ def gridcorner(D, xyz, labels=None, projection='max_slice', max_n_ticks=4,
else:
raise ValueError("Projection {} not understood".format(projection))
fig, axes = plt.subplots(ndim, ndim, figsize=(dim, dim))
# Format the figure.
lb = lbdim / dim
tr = (lbdim + plotdim) / dim
fig.subplots_adjust(left=lb, bottom=lb, right=0.98*tr, top=tr,
wspace=whspace, hspace=whspace)
for i in range(ndim):
projection_1D(
axes[i, i], xyz[i], D, i, projection=projection,
......@@ -141,6 +148,11 @@ def gridcorner(D, xyz, labels=None, projection='max_slice', max_n_ticks=4,
axes[i, 0].set_ylabel(labels[i])
if showDvals:
axes[i, i].set_ylabel(labels[-1])
for ax in axes[:, 0]:
ax.yaxis.set_label_coords(-label_offset, 0.5)
for ax in axes[-1, :]:
ax.xaxis.set_label_coords(0.5, -label_offset)
return fig, axes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment