-
Notifications
You must be signed in to change notification settings - Fork 0
/
_graveyard.py
29 lines (21 loc) · 872 Bytes
/
_graveyard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def set_plot_extents_old(ax=None, x=None, y=None,
m='auto', buff=0.01):
ax = ax or mpl.pyplot.gca()
w, h = get_axes_size()
rat = 1.0*h/w
# todo auto calculate extents if not passed, use above function
if x:
xmin, xmax = x
xbuff = buff*(xmax-xmin)*rat
ax.set_xlim(xmin-xbuff, xmax+xbuff)
if y:
ymin, ymax = y
ybuff = buff*(ymax-ymin)
ax.set_ylim(ymin-ybuff, ymax+ybuff)
# small buffer is used to avoid chopping parts of line off
if m == 'auto':
ax.spines['bottom'].set_position(('axes', -0.03))
ax.spines['left'].set_position(('axes', -0.03*rat)) # same distance as bottom
elif isinstance(m, list): # todo maybe incorporate other options
ax.spines['bottom'].set_position(('axes', m[1]))
ax.spines['left'].set_position(('axes', m[0]))