Python matplotlib.pyplot 模块,quiverkey() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用matplotlib.pyplot.quiverkey()

项目:ImSimDeep    作者:jchiang87    | 项目源码 | 文件源码
def plot_instcat_offsets(df, visit_name, component, fontsize='x-small',
                         field=None, arrow_scale=150.):
    """
    Make a matplotlib.quiver plot of measured position offsets relative
    to the instance catalog values.

    Parameters
    ----------
    df : pandas.DataFrame
        Data frame containing the true and measured coordinates and
        magnitudes and position offsets.
    visit_name : str
        Visit name combining the visit number and filter, e.g., 'v230-fr'.
    component : str
        Name of the component, e.g., 'R2:2' (for the full center raft),
        'R:2,2 S:1,1' (for the central chip).
    fontsize : str or int, optional
        Font size to use in plots.  Default: 'x-small'
    field : (float, float, float, float), optional
        Figure x- and y-dimensions in data units.  Typically set to
        the plt.axis() value from the instcat_overlay plot.
        Default: None (i.e., use default axis range derived from plotted
        data.)
    arrow_scale : float
        Scaling factor for the quiver key arrow.  Default: 150.
    """
    X, Y = df['coord_ra_true'], df['coord_dec_true']
    Xp, Yp = df['coord_ra'], df['coord_dec']
    xhat = Xp - X
    yhat = Yp - Y
    # Set arrow lengths in degrees and apply arrow_scale magnification
    # normalized relative to the nominal x-axis range.
    scale_factor = arrow_scale/3600.
    length = scale_factor*df['offset'].values/np.sqrt(xhat**2 + yhat**2)
    q = plt.quiver(X, Y, length*xhat, length*yhat, units='xy', angles='xy',
                   scale_units='xy', scale=1)
    plt.quiverkey(q, 0.9, 0.9, scale_factor, 'offset (1")', labelpos='N',
                  fontproperties={'size': fontsize})
    if field is not None:
        plt.axis(field)
    plt.xlabel('RA (deg)', fontsize=fontsize)
    plt.ylabel('Dec (deg)', fontsize=fontsize)
    plt.title('%(visit_name)s, %(component)s' % locals(), fontsize=fontsize)