diff --git a/quickstats/plots/template.py b/quickstats/plots/template.py index 3f4f631f650108040946197a37376f069943ec95..bc9ead3a3107608e7f4b73aa42b013d921207301 100644 --- a/quickstats/plots/template.py +++ b/quickstats/plots/template.py @@ -142,6 +142,8 @@ TEMPLATE_STYLES = { }, 'text':{ 'fontsize': 20, + 'verticalalignment': 'top', + 'horizontalalignment': 'left' }, 'plot':{ 'linewidth': 2 @@ -613,6 +615,20 @@ def draw_text(axis, x:float, y:float, s:str, xmin = xmin_ return xmin, xmax, ymin, ymax +def draw_multiline_text(axis, x:float, y:float, + s:str, dy:float=0.01, + transform_x:str='axis', + transform_y:str='axis', + **styles): + components = s.split("//") + for component in components: + _, _, y, _ = draw_text(axis, x, y, component, + transform_x=transform_x, + transform_y=transform_y, + **styles) + y -= dy + transform_x, transform_y = 'axis', 'axis' + @contextmanager def change_axis(axis): """