Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Keitel
gridcorner
Commits
e35ab939
Commit
e35ab939
authored
Feb 27, 2018
by
Gregory Ashton
Browse files
Minor polishing of figure dimensions
parent
c7830615
Changes
1
Hide whitespace changes
Inline
Side-by-side
gridcorner.py
View file @
e35ab939
...
@@ -47,8 +47,24 @@ def idx_array_slice(D, axis, slice_idx):
...
@@ -47,8 +47,24 @@ def idx_array_slice(D, axis, slice_idx):
return
res
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
,
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
""" Generate a grid corner plot
Parameters
Parameters
...
@@ -84,11 +100,9 @@ def gridcorner(D, xyz, labels=None, projection='max_slice', max_n_ticks=4,
...
@@ -84,11 +100,9 @@ def gridcorner(D, xyz, labels=None, projection='max_slice', max_n_ticks=4,
The figure and NxN set of axes
The figure and NxN set of axes
"""
"""
ndim
=
D
.
ndim
ndim
=
D
.
ndim
lbdim
=
0.4
*
factor
# size of left/bottom margin
fig
,
axes
=
_get_fig_and_axes
(
ndim
,
factor
,
whspace
)
trdim
=
0.2
*
factor
# size of top/right margin
plotdim
=
factor
*
ndim
+
factor
*
(
ndim
-
1.
)
*
whspace
dim
=
lbdim
+
plotdim
+
trdim
if
type
(
projection
)
==
str
:
if
type
(
projection
)
==
str
:
if
projection
in
[
'log_mean'
]:
if
projection
in
[
'log_mean'
]:
...
@@ -98,13 +112,6 @@ def gridcorner(D, xyz, labels=None, projection='max_slice', max_n_ticks=4,
...
@@ -98,13 +112,6 @@ def gridcorner(D, xyz, labels=None, projection='max_slice', max_n_ticks=4,
else
:
else
:
raise
ValueError
(
"Projection {} not understood"
.
format
(
projection
))
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
):
for
i
in
range
(
ndim
):
projection_1D
(
projection_1D
(
axes
[
i
,
i
],
xyz
[
i
],
D
,
i
,
projection
=
projection
,
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,
...
@@ -141,6 +148,11 @@ def gridcorner(D, xyz, labels=None, projection='max_slice', max_n_ticks=4,
axes
[
i
,
0
].
set_ylabel
(
labels
[
i
])
axes
[
i
,
0
].
set_ylabel
(
labels
[
i
])
if
showDvals
:
if
showDvals
:
axes
[
i
,
i
].
set_ylabel
(
labels
[
-
1
])
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
return
fig
,
axes
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment