当前位置: 首页>>代码示例>>Python>>正文


Python graph_objs.Annotation方法代码示例

本文整理汇总了Python中plotly.graph_objs.Annotation方法的典型用法代码示例。如果您正苦于以下问题:Python graph_objs.Annotation方法的具体用法?Python graph_objs.Annotation怎么用?Python graph_objs.Annotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plotly.graph_objs的用法示例。


在下文中一共展示了graph_objs.Annotation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: draw_title

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Annotation [as 别名]
def draw_title(self, **props):
        """Add a title to the current subplot in layout dictionary.

        If there exists more than a single plot in the figure, titles revert
        to 'page'-referenced annotations.

        props.keys() -- [
        'text',         (actual content string, not the text obj)
        'position',     (an x, y pair, not an mpl Bbox)
        'coordinates',  ('data', 'axes', 'figure', 'display')
        'text_type',    ('title', 'xlabel', or 'ylabel')
        'style',        (style dict, see below)
        'mplobj'        (actual mpl text object)
        ]

        props['style'].keys() -- [
        'alpha',        (opacity of text)
        'fontsize',     (size in points of text)
        'color',        (hex color)
        'halign',       (horizontal alignment, 'left', 'center', or 'right')
        'valign',       (vertical alignment, 'baseline', 'center', or 'top')
        'rotation',
        'zorder',       (precedence of text when stacked with other objs)
        ]

        """
        self.msg += "        Attempting to draw a title\n"
        if len(self.mpl_fig.axes) > 1:
            self.msg += "          More than one subplot, adding title as " \
                        "annotation\n"
            x_px, y_px = props['mplobj'].get_transform().transform(props[
                'position'])
            x, y = mpltools.display_to_paper(x_px, y_px,
                                             self.plotly_fig['layout'])
            annotation = go.Annotation(
                text=props['text'],
                font=go.Font(
                    color=props['style']['color'],
                    size=props['style']['fontsize']
                ),
                xref='paper',
                yref='paper',
                x=x,
                y=y,
                xanchor='center',
                yanchor='bottom',
                showarrow=False  # no arrow for a title!
            )
            self.plotly_fig['layout']['annotations'] += annotation,
        else:
            self.msg += "          Only one subplot found, adding as a " \
                        "plotly title\n"
            self.plotly_fig['layout']['title'] = props['text']
            titlefont = go.Font(
                size=props['style']['fontsize'],
                color=props['style']['color']
            )
            self.plotly_fig['layout']['titlefont'] = titlefont 
开发者ID:jeanfeydy,项目名称:lddmm-ot,代码行数:60,代码来源:renderer.py


注:本文中的plotly.graph_objs.Annotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。