Ejemplo n.º 1
0
def visualize(profile):
    """
    Automatically creates plots for the provided data structure. In some cases
    many plots are created. For example, when a MatrixProfile is passed with
    corresponding motifs and discords, the matrix profile, discords and motifs
    will be plotted.

    Parameters
    ----------
    profile : dict_like
        A MatrixProfile, Pan-MatrixProfile or Statistics data structure.

    Returns
    -------
    list : figures
        A list of matplotlib figures.

    """
    figures = []

    if not is_visualizable(profile):
        raise ValueError(
            'MatrixProfile, Pan-MatrixProfile or Statistics data structure expected!'
        )

    # plot MP
    if core.is_mp_obj(profile):
        figures = __combine(figures, plot_mp(profile))

        if 'cmp' in profile and len(profile['cmp']) > 0:
            figures = __combine(figures, plot_cmp_mp(profile))

        if 'av' in profile and len(profile['av']) > 0:
            figures = __combine(figures, plot_av_mp(profile))

        if 'motifs' in profile and len(profile['motifs']) > 0:
            figures = __combine(figures, plot_motifs_mp(profile))

        if 'discords' in profile and len(profile['discords']) > 0:
            figures = __combine(figures, plot_discords_mp(profile))

    # plot PMP
    if core.is_pmp_obj(profile):
        figures = __combine(figures, plot_pmp(profile))

        if 'motifs' in profile and len(profile['motifs']) > 0:
            figures = __combine(figures, plot_motifs_pmp(profile))

        if 'discords' in profile and len(profile['discords']) > 0:
            figures = __combine(figures, plot_discords_pmp(profile))

    # plot stats
    if core.is_stats_obj(profile):
        figures = __combine(figures, plot_stats(profile))

    return figures
Ejemplo n.º 2
0
def is_visualizable(obj):
    """
    Helper function to determine if the passed in object can be visualized or
    not based on the data structure.

    Parameters
    ----------
    obj : Object
        The object to test.

    Returns
    -------
    A list of matplotlib figures.
    """
    return core.is_mp_obj(obj) or core.is_pmp_obj(obj) or core.is_stats_obj(obj)