phiplot.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:phiplot 作者: grahamfindlay 项目源码 文件源码
def plot_concept(concept, fig=None, subplot_spec=None, **kwargs):
    """Plot a concept's cause- and effect-repertoires side-by-side, with some
    additional metainfo.

    Examples:
        >>> # Create an 8-inch by 2-inch figure and plot on it.
        >>> A = pyphi.compute.concept(sub, ('A',))
        >>> fig = matplotlib.pyplot.figure(1, (8, 2))
        >>> plot_concept(A, fig=fig, state_fmt='ABC') # use node labels
        >>> matplotlib.pyplot.show()

    Args:
        concept (pyphi.models.Concept): The concept to plot.

    Keyword args:
        fig (matplotlib.Figure): A figure on which to plot. If none is provided,
            a new figure is created and used. Default *None*.
        subplot_spec (matplotlib.gridspec.GridSpec): A gridspec object indicating
            where on a figure to plot. If none is provided, the whole figure is
            used. Default *None*.
        Any unmatched kwargs are passed to `plot_cause_repertoire` and
            `plot_effect_repertoire`.
    """

    if fig is None:
        fig = plt.figure()

    if subplot_spec is None and fig is not None:
        # Divide the plotting area into a 1-row by 9-column grid.
        gs = gridspec.GridSpec(1, 9)
    else:
        gs = gridspec.GridSpecFromSubplotSpec(1, 9, subplot_spec=subplot_spec)

    summary_ax = plt.Subplot(fig, gs[0, 4]) # Use the middle column for metainfo
    cause_ax = plt.Subplot(fig, gs[0, 0:4]) # Span the leftmost 4 columns
    effect_ax = plt.Subplot(fig, gs[0, 5:9]) # Span the rightmost 4 columns
    fig.add_subplot(summary_ax)
    fig.add_subplot(cause_ax)
    fig.add_subplot(effect_ax)
    summary_ax.text(.5, .5, fmt.concept_summary(concept),
                    horizontalalignment='center', verticalalignment='center',
                    multialignment='center')
    summary_ax.axis('off')
    plot_cause_repertoire(concept, ax=cause_ax, **kwargs)
    plot_effect_repertoire(concept, ax=effect_ax, **kwargs)
    effect_ax.set_yticklabels([])

    fig.tight_layout()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号