From 66f7b637e85487a6e8335777895282c2f588ed66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cmahdis-z=E2=80=9D?= Date: Fri, 7 Feb 2020 12:25:03 -0500 Subject: [PATCH] removed go.layout. in docs --- doc/python/custom-buttons.md | 32 +++++++------- doc/python/dropdowns.md | 34 +++++++------- doc/python/images.md | 16 +++---- doc/python/lines-on-maps.md | 2 +- doc/python/mixed-subplots.md | 2 +- doc/python/range-slider.md | 22 ++++----- doc/python/scattermapbox.md | 16 +++---- doc/python/setting-graph-size.md | 10 ++--- doc/python/shapes.md | 71 ++++++++++++------------------ doc/python/templates.md | 36 +++++++-------- doc/python/text-and-annotations.md | 22 ++++----- 11 files changed, 121 insertions(+), 142 deletions(-) diff --git a/doc/python/custom-buttons.md b/doc/python/custom-buttons.md index db1a33e37ae..33c76ec9218 100644 --- a/doc/python/custom-buttons.md +++ b/doc/python/custom-buttons.md @@ -5,8 +5,8 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.1' - jupytext_version: 1.1.7 + format_version: '1.2' + jupytext_version: 1.3.2 kernelspec: display_name: Python 3 language: python @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.7.2 + version: 3.7.3 plotly: description: How to add custom buttons to update Plotly chart attributes in Python. display_as: controls @@ -78,7 +78,7 @@ fig.update_scenes( # Add dropdown fig.update_layout( updatemenus=[ - go.layout.Updatemenu( + dict( type = "buttons", direction = "left", buttons=list([ @@ -106,7 +106,7 @@ fig.update_layout( # Add annotation fig.update_layout( annotations=[ - go.layout.Annotation(text="Trace type:", showarrow=False, + dict(text="Trace type:", showarrow=False, x=0, y=1.08, yref="paper", align="left") ] ) @@ -153,7 +153,7 @@ button_layer_2_height = 1.065 fig.update_layout( updatemenus=[ - go.layout.Updatemenu( + dict( buttons=list([ dict( args=["colorscale", "Viridis"], @@ -185,7 +185,7 @@ fig.update_layout( y=button_layer_1_height, yanchor="top" ), - go.layout.Updatemenu( + dict( buttons=list([ dict( args=["reversescale", False], @@ -207,7 +207,7 @@ fig.update_layout( y=button_layer_2_height, yanchor="top" ), - go.layout.Updatemenu( + dict( buttons=list([ dict( args=[{"contours.showlines": False, "type": "contour"}], @@ -234,11 +234,11 @@ fig.update_layout( fig.update_layout( annotations=[ - go.layout.Annotation(text="colorscale", x=0, xref="paper", y=1.1, yref="paper", + dict(text="colorscale", x=0, xref="paper", y=1.1, yref="paper", align="left", showarrow=False), - go.layout.Annotation(text="Reverse
Colorscale", x=0, xref="paper", y=1.06, + dict(text="Reverse
Colorscale", x=0, xref="paper", y=1.06, yref="paper", showarrow=False), - go.layout.Annotation(text="Lines", x=0.47, xref="paper", y=1.045, yref="paper", + dict(text="Lines", x=0.47, xref="paper", y=1.045, yref="paper", showarrow=False) ]) @@ -296,17 +296,17 @@ fig.add_trace( ) # Add buttons that add shapes -cluster0 = [go.layout.Shape(type="circle", +cluster0 = [dict(type="circle", xref="x", yref="y", x0=min(x0), y0=min(y0), x1=max(x0), y1=max(y0), line=dict(color="DarkOrange"))] -cluster1 = [go.layout.Shape(type="circle", +cluster1 = [dict(type="circle", xref="x", yref="y", x0=min(x1), y0=min(y1), x1=max(x1), y1=max(y1), line=dict(color="Crimson"))] -cluster2 = [go.layout.Shape(type="circle", +cluster2 = [dict(type="circle", xref="x", yref="y", x0=min(x2), y0=min(y2), x1=max(x2), y1=max(y2), @@ -314,7 +314,7 @@ cluster2 = [go.layout.Shape(type="circle", fig.update_layout( updatemenus=[ - go.layout.Updatemenu( + dict( type="buttons", buttons=[ dict(label="None", @@ -415,7 +415,7 @@ low_annotations = [dict(x="2015-05-01", fig.update_layout( updatemenus=[ - go.layout.Updatemenu( + dict( type="buttons", direction="right", active=0, diff --git a/doc/python/dropdowns.md b/doc/python/dropdowns.md index 0ed8bae636e..ca9a77df2e2 100644 --- a/doc/python/dropdowns.md +++ b/doc/python/dropdowns.md @@ -5,8 +5,8 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.1' - jupytext_version: 1.1.1 + format_version: '1.2' + jupytext_version: 1.3.2 kernelspec: display_name: Python 3 language: python @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.6.7 + version: 3.7.3 plotly: description: How to add dropdowns to update Plotly chart attributes in Python. display_as: controls @@ -80,7 +80,7 @@ fig.update_scenes( # Add dropdown fig.update_layout( updatemenus=[ - go.layout.Updatemenu( + dict( buttons=list([ dict( args=["type", "surface"], @@ -107,8 +107,8 @@ fig.update_layout( # Add annotation fig.update_layout( annotations=[ - go.layout.Annotation(text="Trace type:", showarrow=False, - x=0, y=1.085, yref="paper", align="left") + dict(text="Trace type:", showarrow=False, + x=0, y=1.085, yref="paper", align="left") ] ) @@ -151,7 +151,7 @@ fig.update_scenes( button_layer_1_height = 1.08 fig.update_layout( updatemenus=[ - go.layout.Updatemenu( + dict( buttons=list([ dict( args=["colorscale", "Viridis"], @@ -182,7 +182,7 @@ fig.update_layout( y=button_layer_1_height, yanchor="top" ), - go.layout.Updatemenu( + dict( buttons=list([ dict( args=["reversescale", False], @@ -203,7 +203,7 @@ fig.update_layout( y=button_layer_1_height, yanchor="top" ), - go.layout.Updatemenu( + dict( buttons=list([ dict( args=[{"contours.showlines": False, "type": "contour"}], @@ -229,11 +229,11 @@ fig.update_layout( fig.update_layout( annotations=[ - go.layout.Annotation(text="colorscale", x=0, xref="paper", y=1.06, yref="paper", + dict(text="colorscale", x=0, xref="paper", y=1.06, yref="paper", align="left", showarrow=False), - go.layout.Annotation(text="Reverse
Colorscale", x=0.25, xref="paper", y=1.07, + dict(text="Reverse
Colorscale", x=0.25, xref="paper", y=1.07, yref="paper", showarrow=False), - go.layout.Annotation(text="Lines", x=0.54, xref="paper", y=1.06, yref="paper", + dict(text="Lines", x=0.54, xref="paper", y=1.06, yref="paper", showarrow=False) ]) @@ -293,17 +293,17 @@ fig.add_trace( ) # Add buttons that add shapes -cluster0 = [go.layout.Shape(type="circle", +cluster0 = [dict(type="circle", xref="x", yref="y", x0=min(x0), y0=min(y0), x1=max(x0), y1=max(y0), line=dict(color="DarkOrange"))] -cluster1 = [go.layout.Shape(type="circle", +cluster1 = [dict(type="circle", xref="x", yref="y", x0=min(x1), y0=min(y1), x1=max(x1), y1=max(y1), line=dict(color="Crimson"))] -cluster2 = [go.layout.Shape(type="circle", +cluster2 = [dict(type="circle", xref="x", yref="y", x0=min(x2), y0=min(y2), x1=max(x2), y1=max(y2), @@ -311,7 +311,7 @@ cluster2 = [go.layout.Shape(type="circle", fig.update_layout( updatemenus=[ - go.layout.Updatemenu(buttons=list([ + dict(buttons=list([ dict(label="None", method="relayout", args=["shapes", []]), @@ -411,7 +411,7 @@ low_annotations = [dict(x="2015-05-01", fig.update_layout( updatemenus=[ - go.layout.Updatemenu( + dict( active=0, buttons=list([ dict(label="None", diff --git a/doc/python/images.md b/doc/python/images.md index 4bf287df16c..d20d6c3b05a 100644 --- a/doc/python/images.md +++ b/doc/python/images.md @@ -5,8 +5,8 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.1' - jupytext_version: 1.1.1 + format_version: '1.2' + jupytext_version: 1.3.2 kernelspec: display_name: Python 3 language: python @@ -55,7 +55,7 @@ fig.add_trace( # Add images fig.add_layout_image( - go.layout.Image( + dict( source="https://images.plot.ly/language-icons/api-home/python-logo.png", xref="x", yref="y", @@ -178,12 +178,12 @@ for (x, y), n in zip(simulated_absorptions, names): # Add images fig.add_layout_image( - go.layout.Image( + dict( source="https://raw.githubusercontent.com/michaelbabyn/plot_data/master/benzene.png", x=0.75, y=0.65, )) -fig.add_layout_image(go.layout.Image( +fig.add_layout_image(dict( source="https://raw.githubusercontent.com/michaelbabyn/plot_data/master/naphthalene.png", x=0.9, y=0.3, @@ -201,7 +201,7 @@ fig.update_layout_images(dict( # Add annotations fig.update_layout( annotations=[ - go.layout.Annotation( + dict( x=93.0 / 300, y=0.07 / 0.1, xref="paper", @@ -212,7 +212,7 @@ fig.update_layout( ax=250, ay=-40, ), - go.layout.Annotation( + dict( x=156.0 / 300, y=0.04 / 0.1, xref="paper", @@ -280,7 +280,7 @@ fig.update_yaxes( # Add image fig.add_layout_image( - go.layout.Image( + dict( x=0, sizex=img_width * scale_factor, y=img_height * scale_factor, diff --git a/doc/python/lines-on-maps.md b/doc/python/lines-on-maps.md index 55cb9294396..87389a28631 100644 --- a/doc/python/lines-on-maps.md +++ b/doc/python/lines-on-maps.md @@ -100,7 +100,7 @@ for i in range(len(df_flight_paths)): fig.update_layout( title_text = 'Feb. 2011 American Airline flight paths
(Hover for airport names)', showlegend = False, - geo = go.layout.Geo( + geo = dict( scope = 'north america', projection_type = 'azimuthal equal area', showland = True, diff --git a/doc/python/mixed-subplots.md b/doc/python/mixed-subplots.md index 6e5cf625d40..74b73de2386 100644 --- a/doc/python/mixed-subplots.md +++ b/doc/python/mixed-subplots.md @@ -102,7 +102,7 @@ fig.update_layout( template="plotly_dark", margin=dict(r=10, t=25, b=40, l=60), annotations=[ - go.layout.Annotation( + dict( text="Source: NOAA", showarrow=False, xref="paper", diff --git a/doc/python/range-slider.md b/doc/python/range-slider.md index 63b65a20a08..31b7074007f 100644 --- a/doc/python/range-slider.md +++ b/doc/python/range-slider.md @@ -59,7 +59,7 @@ fig.update_layout( # Add range slider fig.update_layout( - xaxis=go.layout.XAxis( + xaxis=dict( rangeselector=dict( buttons=list([ dict(count=1, @@ -174,7 +174,7 @@ fig.update_traces( # Add annotations fig.update_layout( annotations=[ - go.layout.Annotation( + dict( x="2013-06-01", y=0, arrowcolor="rgba(63, 81, 181, 0.2)", @@ -186,7 +186,7 @@ fig.update_layout( yanchor="bottom", yref="y" ), - go.layout.Annotation( + dict( x="2014-09-13", y=0, arrowcolor="rgba(76, 175, 80, 0.1)", @@ -204,7 +204,7 @@ fig.update_layout( # Add shapes fig.update_layout( shapes=[ - go.layout.Shape( + dict( fillcolor="rgba(63, 81, 181, 0.2)", line={"width": 0}, type="rect", @@ -215,7 +215,7 @@ fig.update_layout( y1=0.95, yref="paper" ), - go.layout.Shape( + dict( fillcolor="rgba(76, 175, 80, 0.1)", line={"width": 0}, type="rect", @@ -231,7 +231,7 @@ fig.update_layout( # Update axes fig.update_layout( - xaxis=go.layout.XAxis( + xaxis=dict( autorange=True, range=["2012-10-31 18:36:37.3129", "2016-05-10 05:23:22.6871"], rangeslider=dict( @@ -240,7 +240,7 @@ fig.update_layout( ), type="date" ), - yaxis=go.layout.YAxis( + yaxis=dict( anchor="x", autorange=True, domain=[0, 0.2], @@ -256,7 +256,7 @@ fig.update_layout( type="linear", zeroline=False ), - yaxis2=go.layout.YAxis( + yaxis2=dict( anchor="x", autorange=True, domain=[0.2, 0.4], @@ -272,7 +272,7 @@ fig.update_layout( type="linear", zeroline=False ), - yaxis3=go.layout.YAxis( + yaxis3=dict( anchor="x", autorange=True, domain=[0.4, 0.6], @@ -289,7 +289,7 @@ fig.update_layout( type="linear", zeroline=False ), - yaxis4=go.layout.YAxis( + yaxis4=dict( anchor="x", autorange=True, domain=[0.6, 0.8], @@ -306,7 +306,7 @@ fig.update_layout( type="linear", zeroline=False ), - yaxis5=go.layout.YAxis( + yaxis5=dict( anchor="x", autorange=True, domain=[0.8, 1], diff --git a/doc/python/scattermapbox.md b/doc/python/scattermapbox.md index d8383dd3171..40290fe992a 100644 --- a/doc/python/scattermapbox.md +++ b/doc/python/scattermapbox.md @@ -5,8 +5,8 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: "1.1" - jupytext_version: 1.1.1 + format_version: '1.2' + jupytext_version: 1.3.2 kernelspec: display_name: Python 3 language: python @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.6.8 + version: 3.7.3 plotly: description: How to make scatter plots on Mapbox maps in Python. display_as: maps @@ -71,7 +71,7 @@ fig = go.Figure(go.Scattermapbox( fig.update_layout( hovermode='closest', - mapbox=go.layout.Mapbox( + mapbox=dict( accesstoken=mapbox_access_token, bearing=0, center=go.layout.mapbox.Center( @@ -118,10 +118,10 @@ fig = go.Figure(go.Scattermapbox( fig.update_layout( autosize=True, hovermode='closest', - mapbox=go.layout.Mapbox( + mapbox=dict( accesstoken=mapbox_access_token, bearing=0, - center=go.layout.mapbox.Center( + center=dict( lat=38.92, lon=-77.07 ), @@ -178,10 +178,10 @@ fig.update_layout( autosize=True, hovermode='closest', showlegend=False, - mapbox=go.layout.Mapbox( + mapbox=dict( accesstoken=mapbox_access_token, bearing=0, - center=go.layout.mapbox.Center( + center=dict( lat=38, lon=-94 ), diff --git a/doc/python/setting-graph-size.md b/doc/python/setting-graph-size.md index a2d3e51821d..3c12d1911a2 100644 --- a/doc/python/setting-graph-size.md +++ b/doc/python/setting-graph-size.md @@ -5,8 +5,8 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: "1.1" - jupytext_version: 1.1.7 + format_version: '1.2' + jupytext_version: 1.3.2 kernelspec: display_name: Python 3 language: python @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.6.5 + version: 3.7.3 plotly: description: How to manipulate the graph size in Python with Plotly. display_as: file_settings @@ -65,7 +65,7 @@ fig.update_layout( autosize=False, width=500, height=500, - margin=go.layout.Margin( + margin=dict( l=50, r=50, b=100, @@ -97,7 +97,7 @@ fig.update_layout( autosize=False, width=500, height=500, - yaxis=go.layout.YAxis( + yaxis=dict( title_text="Y-axis Title", ticktext=["Very long label", "long label", "3", "label"], tickvals=[1, 2, 3, 4], diff --git a/doc/python/shapes.md b/doc/python/shapes.md index d0ae16b9e7d..c6ef51585c8 100644 --- a/doc/python/shapes.md +++ b/doc/python/shapes.md @@ -5,8 +5,8 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.1' - jupytext_version: 1.2.1 + format_version: '1.2' + jupytext_version: 1.3.2 kernelspec: display_name: Python 3 language: python @@ -77,7 +77,7 @@ fig.update_yaxes(range=[0, 2.5]) # Add shapes fig.add_shape( # Line Vertical - go.layout.Shape( + dict( type="line", x0=1, y0=0, @@ -90,7 +90,6 @@ fig.add_shape( )) fig.add_shape( # Line Horizontal - go.layout.Shape( type="line", x0=2, y0=2, @@ -101,10 +100,9 @@ fig.add_shape( width=4, dash="dashdot", ), - )) + ) fig.add_shape( # Line Diagonal - go.layout.Shape( type="line", x0=4, y0=0, @@ -115,7 +113,7 @@ fig.add_shape( width=4, dash="dot", ) -)) +) fig.update_shapes(dict(xref='x', yref='y')) fig.show() ``` @@ -143,7 +141,6 @@ fig.update_yaxes(range=[0, 2]) # Add shapes fig.add_shape( # Line reference to the axes - go.layout.Shape( type="line", xref="x", yref="y", @@ -155,10 +152,8 @@ fig.add_shape( color="LightSeaGreen", width=3, ), - )) + ) fig.add_shape( - # Line reference to the plot - go.layout.Shape( type="line", xref="paper", yref="paper", @@ -170,8 +165,7 @@ fig.add_shape( color="DarkOrange", width=3, ), - ), -) + ) fig.show() ``` @@ -202,29 +196,26 @@ fig.update_layout( # Add tangent line shapes fig.add_shape( - go.layout.Shape( type="line", x0=1, y0=2.30756, x1=1.75, y1=2.30756, - )) + ) fig.add_shape( - go.layout.Shape( type="line", x0=2.5, y0=3.80796, x1=3.05, y1=3.80796, - )) + ) fig.add_shape( - go.layout.Shape( type="line", x0=1.90, y0=-1.1827, x1=2.50, y1=-1.1827, - )) + ) fig.update_shapes(dict( xref="x", yref="y", @@ -257,7 +248,6 @@ fig.update_yaxes(range=[0, 3.5]) # Add shapes fig.add_shape( # unfilled Rectangle - go.layout.Shape( type="rect", x0=1, y0=1, @@ -266,10 +256,9 @@ fig.add_shape( line=dict( color="RoyalBlue", ), - )) + ) fig.add_shape( # filled Rectangle - go.layout.Shape( type="rect", x0=3, y0=1, @@ -280,7 +269,7 @@ fig.add_shape( width=2, ), fillcolor="LightSkyBlue", - )) + ) fig.update_shapes(dict(xref='x', yref='y')) fig.show() ``` @@ -308,7 +297,6 @@ fig.update_yaxes(range=[0, 4]) # Add shapes fig.add_shape( # Rectangle reference to the axes - go.layout.Shape( type="rect", xref="x", yref="y", @@ -321,10 +309,9 @@ fig.add_shape( width=3, ), fillcolor="LightSkyBlue", - )) + ) fig.add_shape( # Rectangle reference to the plot - go.layout.Shape( type="rect", xref="paper", yref="paper", @@ -337,7 +324,7 @@ fig.add_shape( width=3, ), fillcolor="PaleTurquoise", - )) + ) fig.show() ``` @@ -367,7 +354,7 @@ fig.add_trace(go.Scatter( fig.update_layout( shapes=[ # 1st highlight during Feb 4 - Feb 6 - go.layout.Shape( + dict( type="rect", # x-reference is assigned to the x-values xref="x", @@ -383,7 +370,7 @@ fig.update_layout( line_width=0, ), # 2nd highlight during Feb 20 - Feb 23 - go.layout.Shape( + dict( type="rect", xref="x", yref="paper", @@ -426,7 +413,7 @@ fig.update_yaxes(range=[0, 4.5]) fig.update_layout( shapes=[ # unfilled circle - go.layout.Shape( + dict( type="circle", xref="x", yref="y", @@ -437,7 +424,7 @@ fig.update_layout( line_color="LightSeaGreen", ), # filled circle - go.layout.Shape( + dict( type="circle", xref="x", yref="y", @@ -506,7 +493,7 @@ fig.add_trace(go.Scatter( # Add shapes fig.update_layout( shapes=[ - go.layout.Shape( + dict( type="circle", xref="x", yref="y", @@ -518,7 +505,7 @@ fig.update_layout( fillcolor="blue", line_color="blue", ), - go.layout.Shape( + dict( type="circle", xref="x", yref="y", @@ -530,7 +517,7 @@ fig.update_layout( fillcolor="orange", line_color="orange", ), - go.layout.Shape( + dict( type="circle", xref="x", yref="y", @@ -542,7 +529,7 @@ fig.update_layout( fillcolor="green", line_color="green", ), - go.layout.Shape( + dict( type="circle", xref="x", yref="y", @@ -598,7 +585,6 @@ fig.update_yaxes( # Add circles fig.add_shape( - go.layout.Shape( type="circle", fillcolor="blue", x0=0, @@ -606,9 +592,8 @@ fig.add_shape( x1=2, y1=2, line_color="blue" - )) + ) fig.add_shape( - go.layout.Shape( type="circle", fillcolor="gray", x0=1.5, @@ -616,7 +601,7 @@ fig.add_shape( x1=3.5, y1=2, line_color="gray" - )) + ) fig.update_shapes(dict( opacity=0.3, xref="x", @@ -671,26 +656,26 @@ fig.update_yaxes( fig.update_layout( shapes=[ # Quadratic Bezier Curves - go.layout.Shape( + dict( type="path", path="M 4,4 Q 6,0 8,4", line_color="RoyalBlue", ), # Cubic Bezier Curves - go.layout.Shape( + dict( type="path", path="M 1,4 C 2,8 6,4 8,8", line_color="MediumPurple", ), # filled Triangle - go.layout.Shape( + dict( type="path", path=" M 1 1 L 1 3 L 4 1 Z", fillcolor="LightPink", line_color="Crimson", ), # filled Polygon - go.layout.Shape( + dict( type="path", path=" M 3,7 L2,8 L2,9 L3,10, L4,10 L5,9 L5,8 L4,7 Z", fillcolor="PaleTurquoise", diff --git a/doc/python/templates.md b/doc/python/templates.md index fbf8e438816..1d50635b948 100644 --- a/doc/python/templates.md +++ b/doc/python/templates.md @@ -5,8 +5,8 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: "1.1" - jupytext_version: 1.1.6 + format_version: '1.2' + jupytext_version: 1.3.2 kernelspec: display_name: Python 3 language: python @@ -23,14 +23,14 @@ jupyter: version: 3.7.3 plotly: description: Theming and templates with plotly with Python - language: python display_as: file_settings + language: python + layout: base name: Theming and templates + order: 7 page_type: u-guide - layout: base permalink: python/templates/ thumbnail: thumbnail/theming-and-templates.png - order: 7 --- ### Theming and templates @@ -141,7 +141,7 @@ Here is an example that creates a template that sets the default title font to s ```python import plotly.graph_objects as go -large_rockwell_template = go.layout.Template( +large_rockwell_template = dict( layout=go.Layout(title_font=dict(family="Rockwell", size=24)) ) @@ -196,7 +196,7 @@ Note that because we built the template with a list of 3 scatter trace graph obj #### Theming object tuple properties -Some properties in the figure hierarchy are specified as tuples of objects. For example, the text annotations for a graph object figure are stored as a tuple of `go.layout.Annotation` objects in the `annotations` property of the figure's layout. +Some properties in the figure hierarchy are specified as tuples of objects. For example, the text annotations for a graph object figure can be stored as a tuple of `go.layout.Annotation` objects in the `annotations` property of the figure's layout. To use a template to configure the default properties of all of the elements in an object tuple property (e.g. `layout.annotations`), use the `*defaults` property in the template that corresponds to the tuple property (e.g. `layout.template.layout.annotationdefaults`). The `*defaults` template property should be set to a single graph object that matches the type of the elements of the corresponding tuple. The properties of this `*defaults` object in the template will be applied to all elements of the object tuple in the figure that the template is applied to. @@ -206,14 +206,14 @@ Here is an example that creates a template that specifies the default annotation import plotly.graph_objects as go annotation_template = go.layout.Template() -annotation_template.layout.annotationdefaults = go.layout.Annotation(font=dict(color="crimson")) +annotation_template.layout.annotationdefaults = dict(font=dict(color="crimson")) fig = go.Figure() fig.update_layout( template=annotation_template, annotations=[ - go.layout.Annotation(text="Look Here", x=1, y=1), - go.layout.Annotation(text="Look There", x=2, y=2) + dict(text="Look Here", x=1, y=1), + dict(text="Look There", x=2, y=2) ] ) fig.show() @@ -232,7 +232,7 @@ import plotly.graph_objects as go draft_template = go.layout.Template() draft_template.layout.annotations = [ - go.layout.Annotation( + dict( name="draft watermark", text="DRAFT", textangle=-30, @@ -262,7 +262,7 @@ import plotly.graph_objects as go draft_template = go.layout.Template() draft_template.layout.annotations = [ - go.layout.Annotation( + dict( name="draft watermark", text="DRAFT", textangle=-30, @@ -280,7 +280,7 @@ fig = go.Figure() fig.update_layout( template=draft_template, annotations=[ - go.layout.Annotation( + dict( templateitemname="draft watermark", text="CONFIDENTIAL", ) @@ -301,7 +301,7 @@ import plotly.io as pio pio.templates["draft"] = go.layout.Template( layout_annotations=[ - go.layout.Annotation( + dict( name="draft watermark", text="DRAFT", textangle=-30, @@ -331,7 +331,7 @@ import plotly.io as pio pio.templates["draft"] = go.layout.Template( layout_annotations=[ - go.layout.Annotation( + dict( name="draft watermark", text="DRAFT", textangle=-30, @@ -365,7 +365,7 @@ import plotly.io as pio pio.templates["draft"] = go.layout.Template( layout_annotations=[ - go.layout.Annotation( + dict( name="draft watermark", text="DRAFT", textangle=-30, @@ -393,7 +393,7 @@ import plotly.express as px pio.templates["draft"] = go.layout.Template( layout_annotations=[ - go.layout.Annotation( + dict( name="draft watermark", text="DRAFT", textangle=-30, @@ -435,7 +435,7 @@ import plotly.io as pio pio.templates["draft"] = go.layout.Template( layout_annotations=[ - go.layout.Annotation( + dict( name="draft watermark", text="DRAFT", textangle=-30, diff --git a/doc/python/text-and-annotations.md b/doc/python/text-and-annotations.md index 6e86c1a0500..d56abb8994e 100644 --- a/doc/python/text-and-annotations.md +++ b/doc/python/text-and-annotations.md @@ -6,7 +6,7 @@ jupyter: extension: .md format_name: markdown format_version: '1.2' - jupytext_version: 1.3.0 + jupytext_version: 1.3.2 kernelspec: display_name: Python 3 language: python @@ -168,7 +168,7 @@ fig.add_trace(go.Scatter( fig.update_layout( showlegend=False, annotations=[ - go.layout.Annotation( + dict( x=2, y=5, xref="x", @@ -204,17 +204,13 @@ fig.add_trace(go.Scatter( )) fig.add_annotation( - go.layout.Annotation( x=2, y=5, text="dict Text") -) fig.add_annotation( - go.layout.Annotation( x=4, y=4, text="dict Text 2") -) fig.update_annotations(dict( xref="x", yref="y", @@ -244,7 +240,9 @@ fig.add_trace(go.Scatter3d( )) fig.update_layout( - scene=go.layout.Scene( + xaxis=dict(title_text="x"), + yaxis=dict(title_text="y"), + scene=dict( aspectratio=dict( x=1, y=1, @@ -317,8 +315,6 @@ fig.update_layout( yanchor="bottom" )] ), - xaxis=dict(title_text="x"), - yaxis=dict(title_text="y") ) fig.show() @@ -382,7 +378,6 @@ fig.add_trace(go.Scatter( )) fig.add_annotation( - go.layout.Annotation( x=2, y=5, xref="x", @@ -407,7 +402,6 @@ fig.add_annotation( bgcolor="#ff7f0e", opacity=0.8 ) -) fig.update_layout(showlegend=False) fig.show() @@ -475,7 +469,7 @@ fig.add_trace(go.Scattergeo( fig.update_layout( title_text="Canadian cities", - geo=go.layout.Geo( + geo=dict( lataxis=dict(range=[40, 70]), lonaxis=dict(range=[-130, -55]), scope="north america" @@ -500,7 +494,7 @@ fig.add_trace(go.Scatter( fig.update_layout( annotations=[ - go.layout.Annotation( + dict( x=0.5, y=-0.15, showarrow=False, @@ -508,7 +502,7 @@ fig.update_layout( xref="paper", yref="paper" ), - go.layout.Annotation( + dict( x=-0.07, y=0.5, showarrow=False,