New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of separate horizontal/vertical axes padding to the axis_grid toolkit #2466
Changes from 4 commits
fb52e4f
3f988d4
856a82f
d089d34
318dd26
f02d214
6fb8607
ccd6ee0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,13 @@ | |
|
||
#import numpy as np | ||
|
||
def extend_axes_pad(value): | ||
# Check whether a list/tuple/array or scalar has been passed | ||
ret = value | ||
if not hasattr(ret, "__getitem__"): | ||
ret = (value, value) | ||
return ret | ||
|
||
def _tick_only(ax, bottom_on, left_on): | ||
bottom_off = not bottom_on | ||
left_off = not left_on | ||
|
@@ -201,6 +208,8 @@ def __init__(self, fig, | |
================ ======== ========================================= | ||
direction "row" [ "row" | "column" ] | ||
axes_pad 0.02 float| pad between axes given in inches | ||
or tuple-like of floats, | ||
(horizontal padding, vertical padding) | ||
add_all True [ True | False ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be better to add an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although I don't insist on anything, there are some good reasons for my approach:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. I had been thinking about them as pure kwargs and forgot about calling with only positional arguments, I now agree as written is the right way to do this. |
||
share_all False [ True | False ] | ||
share_x True [ True | False ] | ||
|
@@ -314,10 +323,11 @@ def __init__(self, fig, | |
|
||
|
||
def _init_axes_pad(self, axes_pad): | ||
axes_pad = extend_axes_pad(axes_pad) | ||
self._axes_pad = axes_pad | ||
|
||
self._horiz_pad_size = Size.Fixed(axes_pad) | ||
self._vert_pad_size = Size.Fixed(axes_pad) | ||
self._horiz_pad_size = Size.Fixed(axes_pad[0]) | ||
self._vert_pad_size = Size.Fixed(axes_pad[1]) | ||
|
||
|
||
def _update_locators(self): | ||
|
@@ -382,14 +392,22 @@ def get_geometry(self): | |
|
||
def set_axes_pad(self, axes_pad): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we have both of these functions? They are identical, one should either be an alias for the other. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other function I am referring to is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know why we have them, so I have done as you suggested them. |
||
"set axes_pad" | ||
axes_pad = extend_axes_pad(axes_pad) | ||
self._axes_pad = axes_pad | ||
|
||
self._horiz_pad_size.fixed_size = axes_pad | ||
self._vert_pad_size.fixed_size = axes_pad | ||
self._horiz_pad_size.fixed_size = axes_pad[0] | ||
self._vert_pad_size.fixed_size = axes_pad[1] | ||
|
||
|
||
def get_axes_pad(self): | ||
"get axes_pad" | ||
""" | ||
get axes_pad | ||
|
||
Returns | ||
------- | ||
tuple | ||
Padding in inches, (horizontal pad, vertical pad) | ||
""" | ||
return self._axes_pad | ||
|
||
def set_aspect(self, aspect): | ||
|
@@ -495,6 +513,8 @@ def __init__(self, fig, | |
================ ======== ========================================= | ||
direction "row" [ "row" | "column" ] | ||
axes_pad 0.02 float| pad between axes given in inches | ||
or tuple-like of floats | ||
(horizontal padding, vertical padding) | ||
add_all True [ True | False ] | ||
share_all False [ True | False ] | ||
aspect True [ True | False ] | ||
|
@@ -521,12 +541,15 @@ def __init__(self, fig, | |
|
||
self.ngrids = ngrids | ||
|
||
axes_pad = extend_axes_pad(axes_pad) | ||
self._axes_pad = axes_pad | ||
|
||
self._colorbar_mode = cbar_mode | ||
self._colorbar_location = cbar_location | ||
if cbar_pad is None: | ||
self._colorbar_pad = axes_pad | ||
# horizontal or vertical arrangement? | ||
self._colorbar_pad = axes_pad[0] \ | ||
if cbar_location in ("left", "right") else axes_pad[1] | ||
else: | ||
self._colorbar_pad = cbar_pad | ||
|
||
|
@@ -688,7 +711,7 @@ def _update_locators(self): | |
v_ax_pos = [] | ||
v_cb_pos = [] | ||
for row,ax in enumerate(self._row_refax[::-1]): | ||
if v: v.append(self._horiz_pad_size) #Size.Fixed(self._axes_pad)) | ||
if v: v.append(self._vert_pad_size) #Size.Fixed(self._axes_pad)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you fix the one-line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have addressed it. |
||
|
||
if ax: | ||
sz = Size.AxesY(ax) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this probably should be
_extend_axes_pad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, done.