def make_figure_uhs(extractors, what):
    """
    $ oq plot 'uhs?kind=mean&site_id=0'
    """
    import matplotlib.pyplot as plt
    fig = plt.figure()
    got = {}  # (calc_id, kind) -> curves
    for i, ex in enumerate(extractors):
        uhs = ex.get(what)
        for kind in uhs.kind:
            got[ex.calc_id, kind] = uhs[kind]
    oq = ex.oqparam
    n_poes = len(oq.poes)
    periods = [imt.period for imt in oq.imt_periods()]
    [site] = uhs.site_id
    for j, poe in enumerate(oq.poes):
        ax = fig.add_subplot(n_poes, 1, j + 1)
        ax.set_xlabel('UHS on site %s, poe=%s, inv_time=%dy' %
                      (site, poe, oq.investigation_time))
        ax.set_ylabel('SA')
        for ck, arr in got.items():
            ax.plot(periods, arr[0, :, j], '-', label='%s_%s' % ck)
            ax.plot(periods, arr[0, :, j], '.')
        ax.grid(True)
        ax.legend()
    return plt
def make_figure_uhs ( extractors , what ) : import matplotlib . pyplot as plt fig = plt . figure ( ) got = { } for i , ex in enumerate ( extractors ) : uhs = ex . get ( what ) for kind in uhs . kind : got [ ex . calc_id , kind ] = uhs [ kind ] oq = ex . oqparam n_poes = len ( oq . poes ) periods = [ imt . period for imt in oq . imt_periods ( ) ] [ site ] = uhs . site_id for j , poe in enumerate ( oq . poes ) : ax = fig . add_subplot ( n_poes , 1 , j + 1 ) ax . set_xlabel ( 'UHS on site %s, poe=%s, inv_time=%dy' % ( site , poe , oq . investigation_time ) ) ax . set_ylabel ( 'SA' ) for ck , arr in got . items ( ) : ax . plot ( periods , arr [ 0 , : , j ] , '-' , label = '%s_%s' % ck ) ax . plot ( periods , arr [ 0 , : , j ] , '.' ) ax . grid ( True ) ax . legend ( ) return plt
$ oq plot 'uhs?kind=mean&site_id=0'