notebooks/common.py
def annotate_endpoint(ax, series: pd.Series, end=None, rot=90):
    """Annotate the endpoint of a series on a plot."""
    xlim = ax.get_xlim() 
    span = xlim[1] - xlim[0]
    x = xlim[1] - 0.0075 * span # Based on 2% margins in initiate_plot()
    x = x if end is None else end
    font_size = 13 if rot == 90 else 10
    ax.text(x, series.iloc[-1], 
            f'{round(series.iloc[-1], 1)}',
            ha='left', va='center', rotation=rot, 
            fontsize=font_size)
Annotate the endpoint of a series on a plot.
Annotate the endpoint of a series on a plot.
Annotate the endpoint of a series on a plot .
def annotate_endpoint(ax, series: pd.Series, end=None, rot=90):
    xlim = ax.get_xlim() 
    span = xlim[1] - xlim[0]
    x = xlim[1] - 0.0075 * span 
    x = x if end is None else end
    font_size = 13 if rot == 90 else 10
    ax.text(x, series.iloc[-1], 
            f'{round(series.iloc[-1], 1)}',
            ha='left', va='center', rotation=rot, 
            fontsize=font_size)
def annotate_endpoint ( ax , series : pd . Series , end = None , rot = 90 ) : xlim = ax . get_xlim ( ) span = xlim [ 1 ] - xlim [ 0 ] x = xlim [ 1 ] - 0.0075 * span x = x if end is None else end font_size = 13 if rot == 90 else 10 ax . text ( x , series . iloc [ - 1 ] , f'{round(series.iloc[-1], 1)}' , ha = 'left' , va = 'center' , rotation = rot , fontsize = font_size )
Annotate the endpoint of a series on a plot.
Annotate the endpoint of a series on a plot .
"""Annotate the endpoint of a series on a plot.""" # Based on 2% margins in initiate_plot()
ax
series
pd.Series
end
rot