當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。