Python plotly.graph_objs.Annotation() Examples
The following are 1
code examples of plotly.graph_objs.Annotation().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
plotly.graph_objs
, or try the search function
.
Example #1
Source File: renderer.py From lddmm-ot with MIT License | 4 votes |
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