Commit 2fcc71c4 authored by Gregory Ashton's avatar Gregory Ashton

Adds ability to switch off yticks and labels on RHS

parent 1769ecff
......@@ -48,20 +48,20 @@ def idx_array_slice(D, axis, slice_idx):
def gridcorner(D, xyz, labels=None, projection='max_slice', max_n_ticks=4,
factor=3, whspace=0.05, **kwargs):
factor=3, whspace=0.05, showDvals=True, **kwargs):
""" Generate a grid corner plot
Parameters
----------
D: array_like
N-dimensional data to plot, `D.shape` should be `(n1, n2,..., nn)`,
where `ni`, is the number of grid points along dimension `i`.
N-dimensional data to plot, `D.shape` should be `(n1, n2,..., nN)`,
where `N`, is the number of grid points along dimension `i`.
xyz: list
List of 1-dimensional arrays of coordinates. `xyz[i]` should have
length `ni` (see help for `D`).
length `N` (see help for `D`).
labels: list
N+1 length list of labels; the first N correspond to the coordinates
labels, the final label is for the dependent variable.
labels, the final label is for the dependent (D) variable.
projection: str or func
If a string, one of `{"log_mean", "max_slice"} to use inbuilt functions
to calculate either the logged mean or maximum slice projection. Else
......@@ -69,9 +69,12 @@ def gridcorner(D, xyz, labels=None, projection='max_slice', max_n_ticks=4,
is `gridcorner.max_slice()`, to project out a slice along the
maximum.
max_n_ticks: int
Number of ticks for x and y axis of the `pcolormesh` plots
Number of ticks for x and y axis of the `pcolormesh` plots.
factor: float
Controls the size of one window
Controls the size of one window.
showDvals: bool
If true (default) show the D values on the right-hand-side of the
1D plots and add a label.
Returns
-------
......@@ -102,7 +105,8 @@ def gridcorner(D, xyz, labels=None, projection='max_slice', max_n_ticks=4,
wspace=whspace, hspace=whspace)
for i in range(ndim):
projection_1D(
axes[i, i], xyz[i], D, i, projection=projection, **kwargs)
axes[i, i], xyz[i], D, i, projection=projection,
showDvals=showDvals, **kwargs)
for j in range(ndim):
ax = axes[i, j]
......@@ -133,7 +137,8 @@ def gridcorner(D, xyz, labels=None, projection='max_slice', max_n_ticks=4,
axes[-1, i].set_xlabel(labels[i])
if i > 0:
axes[i, 0].set_ylabel(labels[i])
axes[i, i].set_ylabel(labels[-1])
if showDvals:
axes[i, i].set_ylabel(labels[-1])
return fig, axes
......@@ -147,13 +152,17 @@ def projection_2D(ax, x, y, D, xidx, yidx, projection, **kwargs):
return ax, pax
def projection_1D(ax, x, D, xidx, projection, **kwargs):
def projection_1D(ax, x, D, xidx, projection, showDvals=True,
**kwargs):
flat_idxs = range(D.ndim)
flat_idxs.remove(xidx)
D1D = projection(D, axis=tuple(flat_idxs), **kwargs)
ax.plot(x, D1D)
ax.yaxis.tick_right()
ax.yaxis.set_label_position("right")
if showDvals:
ax.yaxis.tick_right()
ax.yaxis.set_label_position("right")
else:
ax.yaxis.set_ticklabels([])
return ax
......
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