Overhauled Thresh-LP analysis and figures (WIP).
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import string
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib.transforms import BboxTransformTo
|
||||
from itertools import product
|
||||
|
||||
def prepare_fig(nrows, ncols, width=8, height=None, rheight=2, unit=1/2.54,
|
||||
@@ -154,3 +155,19 @@ def strip_zeros(num, right_digits=5):
|
||||
return f'{left}.{right}'
|
||||
return left
|
||||
|
||||
def time_bar(ax, dur, y0=0.9, y1=0.95, xshift=0.5, parent=None, transform=None, **kwargs):
|
||||
t0, t1 = ax.get_xlim()
|
||||
offset = (t1 - t0 - dur) * xshift
|
||||
x0 = t0 + offset
|
||||
x1 = x0 + dur
|
||||
if parent is None:
|
||||
parent = ax
|
||||
if transform is None:
|
||||
transform = BboxTransformTo(parent.bbox)
|
||||
if transform is not ax.transData:
|
||||
trans = ax.transData + transform.inverted()
|
||||
x0 = trans.transform((x0, 0))[0]
|
||||
x1 = trans.transform((x1, 0))[0]
|
||||
parent.add_artist(plt.Rectangle((x0, y0), x1 - x0, y1 - y0,
|
||||
transform=transform, **kwargs))
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user