From 2164784f3cf999cb75c5a923b1aa96bd9d69eefc Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Wed, 6 Nov 2024 14:07:12 -0500 Subject: [PATCH 1/5] update titles --- doc/python/3d-axes.md | 19 +++++++++++--- doc/python/3d-bubble-charts.md | 4 +-- doc/python/3d-camera-controls.md | 18 ++++++------- doc/python/3d-mesh.md | 6 ++--- doc/python/3d-surface-plots.md | 6 ++--- doc/python/animations.md | 4 +-- doc/python/axes.md | 4 +-- doc/python/bar-charts.md | 2 +- doc/python/box-plots.md | 9 ++++--- doc/python/bubble-charts.md | 6 ++--- doc/python/candlestick-charts.md | 8 ++++-- doc/python/choropleth-maps.md | 6 ++++- doc/python/colorscales.md | 10 ++++---- doc/python/continuous-error-bars.md | 4 +-- doc/python/contour-plots.md | 4 +-- doc/python/datashader.md | 2 +- doc/python/figurewidget.md | 2 +- doc/python/heatmaps.md | 2 +- doc/python/horizontal-bar-charts.md | 2 +- doc/python/line-and-scatter.md | 30 +++++++++++----------- doc/python/line-charts.md | 18 ++++++++++--- doc/python/ml-knn.md | 2 +- doc/python/ml-regression.md | 14 ++++++++--- doc/python/ml-roc-pr.md | 39 +++++++++++++++++++++++------ doc/python/ohlc-charts.md | 4 +-- doc/python/plot-data-from-csv.md | 2 +- doc/python/scatter-plots-on-maps.md | 2 +- doc/python/splom.md | 8 +++--- doc/python/tile-scatter-maps.md | 2 +- doc/python/wind-rose-charts.md | 2 +- 30 files changed, 154 insertions(+), 87 deletions(-) diff --git a/doc/python/3d-axes.md b/doc/python/3d-axes.md index a64bf9f29b8..b6ec1d8d3e0 100644 --- a/doc/python/3d-axes.md +++ b/doc/python/3d-axes.md @@ -159,9 +159,22 @@ fig.add_trace(go.Mesh3d(x=(70*np.random.randn(N)), )) fig.update_layout(scene = dict( - xaxis_title='X AXIS TITLE', - yaxis_title='Y AXIS TITLE', - zaxis_title='Z AXIS TITLE'), + xaxis=dict( + title=dict( + text='X AXIS TITLE' + ) + ), + yaxis=dict( + title=dict( + text='Y AXIS TITLE' + ) + ), + zaxis=dict( + title=dict( + text='Z AXIS TITLE' + ) + ), + ), width=700, margin=dict(r=20, b=10, l=10, t=10)) diff --git a/doc/python/3d-bubble-charts.md b/doc/python/3d-bubble-charts.md index 8abaf0fbdcc..e1555f32ab5 100644 --- a/doc/python/3d-bubble-charts.md +++ b/doc/python/3d-bubble-charts.md @@ -77,7 +77,7 @@ fig = go.Figure(data=go.Scatter3d( fig.update_layout(height=800, width=800, - title='Examining Population and Life Expectancy Over Time') + title=dict(text='Examining Population and Life Expectancy Over Time')) fig.show() ``` @@ -116,7 +116,7 @@ fig = go.Figure(data=go.Scatter3d( fig.update_layout( width=800, height=800, - title="Planets!", + title=dict(text="Planets!"), scene=dict( xaxis=dict( title=dict( diff --git a/doc/python/3d-camera-controls.md b/doc/python/3d-camera-controls.md index 5ec5879bb26..749e72f21ee 100644 --- a/doc/python/3d-camera-controls.md +++ b/doc/python/3d-camera-controls.md @@ -53,7 +53,7 @@ z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/a fig = go.Figure(data=go.Surface(z=z_data, showscale=False)) fig.update_layout( - title='Mt Bruno Elevation', + title=dict(text='Mt Bruno Elevation'), width=400, height=400, margin=dict(t=40, r=0, l=20, b=20) ) @@ -85,7 +85,7 @@ z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/a fig = go.Figure(data=go.Surface(z=z_data, showscale=False)) fig.update_layout( - title='Mt Bruno Elevation', + title=dict(text='Mt Bruno Elevation'), width=400, height=400, margin=dict(t=30, r=0, l=20, b=10) ) @@ -112,7 +112,7 @@ z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/a fig = go.Figure(data=go.Surface(z=z_data, showscale=False)) fig.update_layout( - title='Mt Bruno Elevation', + title=dict(text='Mt Bruno Elevation'), width=400, height=400, margin=dict(t=30, r=0, l=20, b=10) ) @@ -138,7 +138,7 @@ z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/a fig = go.Figure(data=go.Surface(z=z_data, showscale=False)) fig.update_layout( - title='Mt Bruno Elevation', + title=dict(text='Mt Bruno Elevation'), width=400, height=400, margin=dict(t=30, r=0, l=20, b=10) ) @@ -163,7 +163,7 @@ z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/a fig = go.Figure(data=go.Surface(z=z_data, showscale=False)) fig.update_layout( - title='Mt Bruno Elevation', + title=dict(text='Mt Bruno Elevation'), width=400, height=400, margin=dict(t=30, r=0, l=20, b=10) ) @@ -189,7 +189,7 @@ z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/a fig = go.Figure(data=go.Surface(z=z_data, showscale=False)) fig.update_layout( - title='Mt Bruno Elevation', + title=dict(text='Mt Bruno Elevation'), width=400, height=400, margin=dict(t=30, r=0, l=20, b=10) ) @@ -216,7 +216,7 @@ z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/a fig = go.Figure(data=go.Surface(z=z_data, showscale=False)) fig.update_layout( - title='Mt Bruno Elevation', + title=dict(text='Mt Bruno Elevation'), width=400, height=400, margin=dict(t=30, r=0, l=20, b=10) ) @@ -243,7 +243,7 @@ z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/a fig = go.Figure(data=go.Surface(z=z_data, showscale=False)) fig.update_layout( - title='Mt Bruno Elevation', + title=dict(text='Mt Bruno Elevation'), width=400, height=400, margin=dict(t=30, r=0, l=20, b=10) ) @@ -273,7 +273,7 @@ z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/a fig = go.Figure(data=go.Surface(z=z_data, showscale=False)) fig.update_layout( - title='Mt Bruno Elevation', + title=dict(text='Mt Bruno Elevation'), width=400, height=400, margin=dict(t=25, r=0, l=20, b=30) ) diff --git a/doc/python/3d-mesh.md b/doc/python/3d-mesh.md index fec2097972e..610c8153a90 100644 --- a/doc/python/3d-mesh.md +++ b/doc/python/3d-mesh.md @@ -97,7 +97,7 @@ fig = go.Figure(data=[ x=[0, 1, 2, 0], y=[0, 0, 1, 2], z=[0, 2, 0, 1], - colorbar_title='z', + colorbar=dict(title=dict(text='z')), colorscale=[[0, 'gold'], [0.5, 'mediumturquoise'], [1, 'magenta']], @@ -128,7 +128,7 @@ fig = go.Figure(data=[ x=[0, 0, 1, 1, 0, 0, 1, 1], y=[0, 1, 1, 0, 0, 1, 1, 0], z=[0, 0, 0, 0, 1, 1, 1, 1], - colorbar_title='z', + colorbar=dict(title=dict(text='z')), colorscale=[[0, 'gold'], [0.5, 'mediumturquoise'], [1, 'magenta']], @@ -160,7 +160,7 @@ fig = go.Figure(data=[ x=[0, 0, 1, 1, 0, 0, 1, 1], y=[0, 1, 1, 0, 0, 1, 1, 0], z=[0, 0, 0, 0, 1, 1, 1, 1], - colorbar_title='z', + colorbar=dict(title=dict(text='z')), colorscale=[[0, 'gold'], [0.5, 'mediumturquoise'], [1, 'magenta']], diff --git a/doc/python/3d-surface-plots.md b/doc/python/3d-surface-plots.md index a7b561e7a6c..8b042d3fcb9 100644 --- a/doc/python/3d-surface-plots.md +++ b/doc/python/3d-surface-plots.md @@ -46,7 +46,7 @@ z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/a fig = go.Figure(data=[go.Surface(z=z_data.values)]) -fig.update_layout(title='Mt Bruno Elevation', autosize=False, +fig.update_layout(title=dict(text='Mt Bruno Elevation'), autosize=False, width=500, height=500, margin=dict(l=65, r=50, b=65, t=90)) @@ -67,7 +67,7 @@ z = z_data.values sh_0, sh_1 = z.shape x, y = np.linspace(0, 1, sh_0), np.linspace(0, 1, sh_1) fig = go.Figure(data=[go.Surface(z=z, x=x, y=y)]) -fig.update_layout(title='Mt Bruno Elevation', autosize=False, +fig.update_layout(title=dict(text='Mt Bruno Elevation'), autosize=False, width=500, height=500, margin=dict(l=65, r=50, b=65, t=90)) fig.show() @@ -90,7 +90,7 @@ z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/a fig = go.Figure(data=[go.Surface(z=z_data.values)]) fig.update_traces(contours_z=dict(show=True, usecolormap=True, highlightcolor="limegreen", project_z=True)) -fig.update_layout(title='Mt Bruno Elevation', autosize=False, +fig.update_layout(title=dict(text='Mt Bruno Elevation'), autosize=False, scene_camera_eye=dict(x=1.87, y=0.88, z=-0.64), width=500, height=500, margin=dict(l=65, r=50, b=65, t=90) diff --git a/doc/python/animations.md b/doc/python/animations.md index e76101cb41c..c61162693e3 100644 --- a/doc/python/animations.md +++ b/doc/python/animations.md @@ -126,7 +126,7 @@ fig = go.Figure( layout=go.Layout( xaxis=dict(range=[0, 5], autorange=False), yaxis=dict(range=[0, 5], autorange=False), - title="Start Title", + title=dict(text="Start Title"), updatemenus=[dict( type="buttons", buttons=[dict(label="Play", @@ -240,7 +240,7 @@ fig = go.Figure( layout=go.Layout(width=600, height=600, xaxis=dict(range=[xm, xM], autorange=False, zeroline=False), yaxis=dict(range=[ym, yM], autorange=False, zeroline=False), - title="Moving Frenet Frame Along a Planar Curve", + title=dict(text="Moving Frenet Frame Along a Planar Curve"), hovermode="closest", updatemenus=[dict(type="buttons", buttons=[dict(label="Play", diff --git a/doc/python/axes.md b/doc/python/axes.md index 851fb142db8..df8672e0e2e 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -649,8 +649,8 @@ import plotly.express as px df = px.data.stocks(indexed=True) fig = px.line(df, df.index, y="GOOG") -fig.update_yaxes(ticklabelposition="inside", title="Price") -fig.update_xaxes(insiderange=['2018-10-01', '2019-01-01'], title="Date") +fig.update_yaxes(ticklabelposition="inside", title=dict(text="Price")) +fig.update_xaxes(insiderange=['2018-10-01', '2019-01-01'], title=dict(text="Date")) fig.show() ``` diff --git a/doc/python/bar-charts.md b/doc/python/bar-charts.md index e93439cf1f9..05d9306e8d4 100644 --- a/doc/python/bar-charts.md +++ b/doc/python/bar-charts.md @@ -616,7 +616,7 @@ fig.add_trace(go.Bar(x=years, )) fig.update_layout( - title='US Export of Plastic Scrap', + title=dict(text='US Export of Plastic Scrap'), xaxis_tickfont_size=14, yaxis=dict( title=dict( diff --git a/doc/python/box-plots.md b/doc/python/box-plots.md index 5ca79d51b0f..244c21106ef 100644 --- a/doc/python/box-plots.md +++ b/doc/python/box-plots.md @@ -367,7 +367,10 @@ fig.add_trace(go.Box( )) fig.update_layout( - yaxis_title='normalized moisture', + yaxis=dict( + title=dict( + text='normalized moisture') + ), boxmode='group' # group together boxes of the different traces for each value of x ) fig.show() @@ -402,7 +405,7 @@ fig.add_trace(go.Box( )) fig.update_layout( - xaxis=dict(title='normalized moisture', zeroline=False), + xaxis=dict(title=dict(text='normalized moisture'), zeroline=False), boxmode='group' ) @@ -479,7 +482,7 @@ for xd, yd, cls in zip(x_data, y_data, colors): ) fig.update_layout( - title='Points Scored by the Top 9 Scoring NBA Players in 2012', + title=dict(text='Points Scored by the Top 9 Scoring NBA Players in 2012'), yaxis=dict( autorange=True, showgrid=True, diff --git a/doc/python/bubble-charts.md b/doc/python/bubble-charts.md index b5bc5ad966d..ad574b2a1ef 100644 --- a/doc/python/bubble-charts.md +++ b/doc/python/bubble-charts.md @@ -202,15 +202,15 @@ fig.update_traces(mode='markers', marker=dict(sizemode='area', sizeref=sizeref, line_width=2)) fig.update_layout( - title='Life Expectancy v. Per Capita GDP, 2007', + title=dict(text='Life Expectancy v. Per Capita GDP, 2007'), xaxis=dict( - title='GDP per capita (2000 dollars)', + title=dict(text='GDP per capita (2000 dollars)'), gridcolor='white', type='log', gridwidth=2, ), yaxis=dict( - title='Life Expectancy (years)', + title=dict(text='Life Expectancy (years)'), gridcolor='white', gridwidth=2, ), diff --git a/doc/python/candlestick-charts.md b/doc/python/candlestick-charts.md index d4b98cc1979..06273b4ad43 100644 --- a/doc/python/candlestick-charts.md +++ b/doc/python/candlestick-charts.md @@ -106,8 +106,12 @@ fig = go.Figure(data=[go.Candlestick(x=df['Date'], ]) fig.update_layout( - title='The Great Recession', - yaxis_title='AAPL Stock', + title=dict(text='The Great Recession'), + yaxis=dict( + title=dict( + text='AAPL Stock' + ) + ), shapes = [dict( x0='2016-12-09', x1='2016-12-09', y0=0, y1=1, xref='x', yref='paper', line_width=2)], diff --git a/doc/python/choropleth-maps.md b/doc/python/choropleth-maps.md index 6cdf73d51e0..e38e51befde 100644 --- a/doc/python/choropleth-maps.md +++ b/doc/python/choropleth-maps.md @@ -287,7 +287,11 @@ fig = go.Figure(data=go.Choropleth( autocolorscale=False, text=df['text'], # hover text marker_line_color='white', # line markers between states - colorbar_title="Millions USD" + colorbar=dict( + title=dict( + text="Millions USD" + ) + ) )) fig.update_layout( diff --git a/doc/python/colorscales.md b/doc/python/colorscales.md index 757ff54911e..61e84314d4d 100644 --- a/doc/python/colorscales.md +++ b/doc/python/colorscales.md @@ -246,7 +246,7 @@ df = px.data.tips() fig = px.density_heatmap(df, x="total_bill", y="tip", title="Customized color bar on this density plot") fig.update_layout(coloraxis_colorbar=dict( - title="Number of Bills per Cell", + title=dict(text="Number of Bills per Cell"), thicknessmode="pixels", thickness=50, lenmode="pixels", len=200, yanchor="top", y=1, @@ -271,7 +271,7 @@ fig = px.parallel_coordinates(df, dimensions=["sepal_length", "sepal_width", "pe (0.66, "blue"), (1.00, "blue")]) fig.update_layout(coloraxis_colorbar=dict( - title="Species", + title=dict(text="Species"), tickvals=[1,2,3], ticktext=["setosa","versicolor","virginica"], lenmode="pixels", len=100, @@ -291,7 +291,7 @@ df = px.data.gapminder().query("year == 2007") fig = px.scatter(df, y="lifeExp", x="pop", color=np.log10(df["pop"]), hover_name="country", log_x=True) fig.update_layout(coloraxis_colorbar=dict( - title="Population", + title=dict(text="Population"), tickvals=[6,7,8,9], ticktext=["1M", "10M", "100M", "1B"], )) @@ -408,7 +408,7 @@ fig.add_trace(go.Scatter( cmin=0, color=values, colorbar=dict( - title="Colorbar" + title=dict(text="Colorbar") ), colorscale="Viridis" ), @@ -659,7 +659,7 @@ fig = go.Figure(go.Heatmap( colorbar=dict( x=0.2, xref="container", - title="Surface Heat" + title=dict(text="Surface Heat") ) )) diff --git a/doc/python/continuous-error-bars.md b/doc/python/continuous-error-bars.md index 9706c0c6ab7..529033bb63d 100644 --- a/doc/python/continuous-error-bars.md +++ b/doc/python/continuous-error-bars.md @@ -108,8 +108,8 @@ fig = go.Figure([ ) ]) fig.update_layout( - yaxis_title='Wind speed (m/s)', - title='Continuous, variable value error bars', + yaxis=dict(title=dict(text='Wind speed (m/s)')), + title=dict(text='Continuous, variable value error bars'), hovermode="x" ) fig.show() diff --git a/doc/python/contour-plots.md b/doc/python/contour-plots.md index 4ba74b175d4..897564ce391 100644 --- a/doc/python/contour-plots.md +++ b/doc/python/contour-plots.md @@ -153,8 +153,8 @@ fig.add_trace(go.Contour(z=z, showscale=False, connectgaps=True), 1, 2) fig.add_trace(go.Heatmap(z=z, showscale=False, zsmooth='best'), 2, 1) fig.add_trace(go.Heatmap(z=z, showscale=False, connectgaps=True, zsmooth='best'), 2, 2) -fig['layout']['yaxis1'].update(title='Contour map') -fig['layout']['yaxis3'].update(title='Heatmap') +fig['layout']['yaxis1'].update(title=dict(text='Contour map')) +fig['layout']['yaxis3'].update(title=dict(text='Heatmap')) fig.show() ``` diff --git a/doc/python/datashader.md b/doc/python/datashader.md index ba1ec46e4fe..b2a21a84976 100644 --- a/doc/python/datashader.md +++ b/doc/python/datashader.md @@ -106,6 +106,6 @@ agg.values = np.log10(agg.values, where=np.logical_not(zero_mask)) agg.values[zero_mask] = np.nan fig = px.imshow(agg, origin='lower', labels={'color':'Log10(count)'}) fig.update_traces(hoverongaps=False) -fig.update_layout(coloraxis_colorbar=dict(title='Count', tickprefix='1.e')) +fig.update_layout(coloraxis_colorbar=dict(title=dict(text='Count'), tickprefix='1.e')) fig.show() ``` diff --git a/doc/python/figurewidget.md b/doc/python/figurewidget.md index 116521f3033..c2d76327e7b 100644 --- a/doc/python/figurewidget.md +++ b/doc/python/figurewidget.md @@ -94,7 +94,7 @@ trace = go.Heatmap(z=[[1, 20, 30, 50, 1], [20, 1, 60, 80, 30], [30, 60, 1, -10, x=['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'], y=['Morning', 'Afternoon', 'Evening']) data=[trace] -layout = go.Layout(title='Activity Heatmap') +layout = go.Layout(title=dict(text='Activity Heatmap')) figure = go.Figure(data=data, layout=layout) diff --git a/doc/python/heatmaps.md b/doc/python/heatmaps.md index d9079ea2845..f8fbb77ad43 100644 --- a/doc/python/heatmaps.md +++ b/doc/python/heatmaps.md @@ -261,7 +261,7 @@ fig = go.Figure(data=go.Heatmap( colorscale='Viridis')) fig.update_layout( - title='GitHub commits per day', + title=dict(text='GitHub commits per day'), xaxis_nticks=36) fig.show() diff --git a/doc/python/horizontal-bar-charts.md b/doc/python/horizontal-bar-charts.md index 25aa9d4f7d1..ae9b02e3d30 100644 --- a/doc/python/horizontal-bar-charts.md +++ b/doc/python/horizontal-bar-charts.md @@ -260,7 +260,7 @@ fig.append_trace(go.Scatter( ), 1, 2) fig.update_layout( - title='Household savings & net worth for eight OECD countries', + title=dict(text='Household savings & net worth for eight OECD countries'), yaxis=dict( showgrid=False, showline=False, diff --git a/doc/python/line-and-scatter.md b/doc/python/line-and-scatter.md index 802f6224173..9ddaad8aac7 100644 --- a/doc/python/line-and-scatter.md +++ b/doc/python/line-and-scatter.md @@ -136,7 +136,7 @@ fig.show() *New in 5.12* -You can configure the gap between groups of scatter points using `scattergap`. Here we set it to `0.75`, which brings the points closer together by allocating more space to the gap between groups. If you don't set `scattergap`, a default value of `0` is used, unless you have `bargap` set. If you have `bargap` set, the `scattergap` defaults to that value. +You can configure the gap between groups of scatter points using `scattergap`. Here we set it to `0.75`, which brings the points closer together by allocating more space to the gap between groups. If you don't set `scattergap`, a default value of `0` is used, unless you have `bargap` set. If you have `bargap` set, the `scattergap` defaults to that value. ```python @@ -250,7 +250,7 @@ fig.show() ### Data Order in Scatter and Line Charts -Plotly line charts are implemented as [connected scatterplots](https://www.data-to-viz.com/graph/connectedscatter.html) (see below), meaning that the points are plotted and connected with lines **in the order they are provided, with no automatic reordering**. +Plotly line charts are implemented as [connected scatterplots](https://www.data-to-viz.com/graph/connectedscatter.html) (see below), meaning that the points are plotted and connected with lines **in the order they are provided, with no automatic reordering**. This makes it possible to make charts like the one below, but also means that it may be required to explicitly sort data before passing it to Plotly to avoid lines moving "backwards" across the chart. @@ -262,17 +262,17 @@ df = pd.DataFrame(dict( x = [1, 3, 2, 4], y = [1, 2, 3, 4] )) -fig = px.line(df, x="x", y="y", title="Unsorted Input") +fig = px.line(df, x="x", y="y", title="Unsorted Input") fig.show() df = df.sort_values(by="x") -fig = px.line(df, x="x", y="y", title="Sorted Input") +fig = px.line(df, x="x", y="y", title="Sorted Input") fig.show() ``` ### Connected Scatterplots -In a connected scatterplot, two continuous variables are plotted against each other, with a line connecting them in some meaningful order, usually a time variable. In the plot below, we show the "trajectory" of a pair of countries through a space defined by GDP per Capita and Life Expectancy. Botswana's life expectancy +In a connected scatterplot, two continuous variables are plotted against each other, with a line connecting them in some meaningful order, usually a time variable. In the plot below, we show the "trajectory" of a pair of countries through a space defined by GDP per Capita and Life Expectancy. Botswana's life expectancy ```python import plotly.express as px @@ -380,7 +380,7 @@ fig.add_trace(go.Scatter( # Set options common to all traces with fig.update_traces fig.update_traces(mode='markers', marker_line_width=2, marker_size=10) -fig.update_layout(title='Styled Scatter', +fig.update_layout(title=dict(text='Styled Scatter'), yaxis_zeroline=False, xaxis_zeroline=False) @@ -401,7 +401,7 @@ fig = go.Figure(data=go.Scatter(x=data['Postal'], marker_color=data['Population'], text=data['State'])) # hover text goes here -fig.update_layout(title='Population of USA States') +fig.update_layout(title=dict(text='Population of USA States')) fig.show() ``` @@ -440,28 +440,28 @@ df = data.gapminder() df_europe = df[df['continent'] == 'Europe'] -trace1 = go.Scatter(x=df_europe[df_europe['country'] == 'France']['year'], - y=df_europe[df_europe['country'] == 'France']['lifeExp'], - mode='lines+markers', +trace1 = go.Scatter(x=df_europe[df_europe['country'] == 'France']['year'], + y=df_europe[df_europe['country'] == 'France']['lifeExp'], + mode='lines+markers', zorder=3, name='France', marker=dict(size=15)) -trace2 = go.Scatter(x=df_europe[df_europe['country'] == 'Germany']['year'], - y=df_europe[df_europe['country'] == 'Germany']['lifeExp'], +trace2 = go.Scatter(x=df_europe[df_europe['country'] == 'Germany']['year'], + y=df_europe[df_europe['country'] == 'Germany']['lifeExp'], mode='lines+markers', zorder=1, name='Germany', marker=dict(size=15)) -trace3 = go.Scatter(x=df_europe[df_europe['country'] == 'Spain']['year'], - y=df_europe[df_europe['country'] == 'Spain']['lifeExp'], +trace3 = go.Scatter(x=df_europe[df_europe['country'] == 'Spain']['year'], + y=df_europe[df_europe['country'] == 'Spain']['lifeExp'], mode='lines+markers', zorder=2, name='Spain', marker=dict(size=15)) -layout = go.Layout(title='Life Expectancy in Europe Over Time') +layout = go.Layout(title=dict(text='Life Expectancy in Europe Over Time')) fig = go.Figure(data=[trace1, trace2, trace3], layout=layout) diff --git a/doc/python/line-charts.md b/doc/python/line-charts.md index 4434aa8046c..840abdfa76c 100644 --- a/doc/python/line-charts.md +++ b/doc/python/line-charts.md @@ -253,9 +253,21 @@ fig.add_trace(go.Scatter(x=month, y=low_2000, name='Low 2000', line=dict(color='royalblue', width=4, dash='dot'))) # Edit the layout -fig.update_layout(title='Average High and Low Temperatures in New York', - xaxis_title='Month', - yaxis_title='Temperature (degrees F)') +fig.update_layout( + title=dict( + text='Average High and Low Temperatures in New York' + ), + xaxis=dict( + title=dict( + text='Month' + ) + ), + yaxis=dict( + title=dict( + text='Temperature (degrees F)' + ) + ), +) fig.show() diff --git a/doc/python/ml-knn.md b/doc/python/ml-knn.md index 132595411f5..28ff33469bd 100644 --- a/doc/python/ml-knn.md +++ b/doc/python/ml-knn.md @@ -323,7 +323,7 @@ fig.add_trace( ) fig.update_layout( legend_orientation='h', - title='Prediction Confidence on Test Split' + title=dict(text='Prediction Confidence on Test Split') ) fig.show() ``` diff --git a/doc/python/ml-regression.md b/doc/python/ml-regression.md index c74b49e92bd..5215058286d 100644 --- a/doc/python/ml-regression.md +++ b/doc/python/ml-regression.md @@ -452,9 +452,17 @@ fig.add_shape( ) fig.update_layout( - xaxis_title='alpha', - xaxis_type="log", - yaxis_title="Mean Square Error (MSE)" + xaxis=dict( + title=dict( + text='alpha' + ), + type='log' + ), + yaxis=dict( + title=dict( + text='Mean Square Error (MSE)' + ) + ), ) fig.show() ``` diff --git a/doc/python/ml-roc-pr.md b/doc/python/ml-roc-pr.md index 20678b8ca82..181e11c5cdb 100644 --- a/doc/python/ml-roc-pr.md +++ b/doc/python/ml-roc-pr.md @@ -187,10 +187,19 @@ for i in range(y_scores.shape[1]): fig.add_trace(go.Scatter(x=fpr, y=tpr, name=name, mode='lines')) fig.update_layout( - xaxis_title='False Positive Rate', - yaxis_title='True Positive Rate', - yaxis=dict(scaleanchor="x", scaleratio=1), - xaxis=dict(constrain='domain'), + xaxis=dict( + title=dict( + text='False Positive Rate' + ), + constrain='domain' + ), + yaxis=dict( + title=dict( + text='True Positive Rate' + ), + scaleanchor='x', + scaleratio=1 + ), width=700, height=500 ) fig.show() @@ -277,10 +286,24 @@ for i in range(y_scores.shape[1]): fig.add_trace(go.Scatter(x=recall, y=precision, name=name, mode='lines')) fig.update_layout( - xaxis_title='Recall', - yaxis_title='Precision', - yaxis=dict(scaleanchor="x", scaleratio=1), - xaxis=dict(constrain='domain'), + xaxis=dict( + title=dict( + text='Recall' + ), + constrain='domain' + ), + yaxis=dict( + title=dict( + text='Precision' + ), + scaleanchor='x', + scaleratio=1 + ), + zaxis=dict( + title=dict( + text='Z AXIS TITLE' + ) + ), width=700, height=500 ) fig.show() diff --git a/doc/python/ohlc-charts.md b/doc/python/ohlc-charts.md index dc6e02ed1f3..f59228b79c0 100644 --- a/doc/python/ohlc-charts.md +++ b/doc/python/ohlc-charts.md @@ -77,8 +77,8 @@ fig = go.Figure(data=go.Ohlc(x=df['Date'], close=df['AAPL.Close'])) fig.update_layout( - title='The Great Recession', - yaxis_title='AAPL Stock', + title=dict(text='The Great Recession'), + yaxis=dict(title=dict(text='AAPL Stock')), shapes = [dict( x0='2016-12-09', x1='2016-12-09', y0=0, y1=1, xref='x', yref='paper', line_width=2)], diff --git a/doc/python/plot-data-from-csv.md b/doc/python/plot-data-from-csv.md index 0050881e037..1f1a30269bd 100644 --- a/doc/python/plot-data-from-csv.md +++ b/doc/python/plot-data-from-csv.md @@ -84,7 +84,7 @@ df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_ fig = go.Figure(go.Scatter(x = df['AAPL_x'], y = df['AAPL_y'], name='Share Prices (in USD)')) -fig.update_layout(title='Apple Share Prices over time (2014)', +fig.update_layout(title=dict(text='Apple Share Prices over time (2014)'), plot_bgcolor='rgb(230, 230,230)', showlegend=True) diff --git a/doc/python/scatter-plots-on-maps.md b/doc/python/scatter-plots-on-maps.md index e22a019eb6e..fc20d7e5b6a 100644 --- a/doc/python/scatter-plots-on-maps.md +++ b/doc/python/scatter-plots-on-maps.md @@ -227,7 +227,7 @@ fig.update_layout( dtick = 5 ) ), - title='US Precipitation 06-30-2015
Source: NOAA', + title=dict(text='US Precipitation 06-30-2015
Source: NOAA'), ) fig.show() ``` diff --git a/doc/python/splom.md b/doc/python/splom.md index 105f7177b4f..f2f562e0513 100644 --- a/doc/python/splom.md +++ b/doc/python/splom.md @@ -136,7 +136,7 @@ fig = go.Figure(data=go.Splom( fig.update_layout( - title='Iris Data set', + title=dict(text='Iris Data set'), dragmode='select', width=600, height=600, @@ -173,7 +173,7 @@ fig = go.Figure(data=go.Splom( fig.update_layout( - title='Iris Data set', + title=dict(text='Iris Data set'), width=600, height=600, ) @@ -208,7 +208,7 @@ fig = go.Figure(data=go.Splom( fig.update_layout( - title='Iris Data set', + title=dict(text='Iris Data set'), width=600, height=600, ) @@ -243,7 +243,7 @@ fig = go.Figure(data=go.Splom( fig.update_layout( - title='Iris Data set', + title=dict(text='Iris Data set'), width=600, height=600, ) diff --git a/doc/python/tile-scatter-maps.md b/doc/python/tile-scatter-maps.md index 82f54d90f3b..899d872f8f3 100644 --- a/doc/python/tile-scatter-maps.md +++ b/doc/python/tile-scatter-maps.md @@ -180,7 +180,7 @@ fig.add_trace(go.Scattermap( )) fig.update_layout( - title='Nuclear Waste Sites on Campus', + title=dict(text='Nuclear Waste Sites on Campus'), autosize=True, hovermode='closest', showlegend=False, diff --git a/doc/python/wind-rose-charts.md b/doc/python/wind-rose-charts.md index bd0d46fc623..40fd2aa87ce 100644 --- a/doc/python/wind-rose-charts.md +++ b/doc/python/wind-rose-charts.md @@ -79,7 +79,7 @@ fig.add_trace(go.Barpolar( fig.update_traces(text=['North', 'N-E', 'East', 'S-E', 'South', 'S-W', 'West', 'N-W']) fig.update_layout( - title='Wind Speed Distribution in Laurel, NE', + title=dict(text='Wind Speed Distribution in Laurel, NE'), font_size=16, legend_font_size=16, polar_radialaxis_ticksuffix='%', From ce8f577f79585c79f9b2a68a69d933d484f7e947 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Wed, 6 Nov 2024 14:30:23 -0500 Subject: [PATCH 2/5] update title to dict --- doc/python/3d-bubble-charts.md | 2 +- doc/python/dot-plots.md | 20 +++++++-- doc/python/dumbbell-plots.md | 18 ++++---- doc/python/figure-labels.md | 46 ++++++++++++++++---- doc/python/hover-text-and-formatting.md | 2 +- doc/python/legend.md | 51 ++++++++++++---------- doc/python/marker-style.md | 14 +++--- doc/python/multiple-axes.md | 58 +++++++++++++++++++------ doc/python/sankey-diagram.md | 10 ++--- doc/python/scatter-plots-on-maps.md | 6 ++- doc/python/shapes.md | 31 +++++++++---- doc/python/splom.md | 2 +- doc/python/templates.md | 6 +-- 13 files changed, 181 insertions(+), 85 deletions(-) diff --git a/doc/python/3d-bubble-charts.md b/doc/python/3d-bubble-charts.md index e1555f32ab5..992b4c74d3c 100644 --- a/doc/python/3d-bubble-charts.md +++ b/doc/python/3d-bubble-charts.md @@ -184,7 +184,7 @@ fig = go.Figure(go.Scatter3d( fig.update_layout( width=800, height=800, - title="Planets!", + title=dict(text="Planets!"), scene=dict( xaxis=dict( title=dict( diff --git a/doc/python/dot-plots.md b/doc/python/dot-plots.md index ed9d7b6c239..5d42411865d 100644 --- a/doc/python/dot-plots.md +++ b/doc/python/dot-plots.md @@ -98,9 +98,21 @@ fig.add_trace(go.Scatter( name="Men", )) -fig.update_layout(title="Gender Earnings Disparity", - xaxis_title="Annual Salary (in thousands)", - yaxis_title="School") +fig.update_layout( + title=dict( + text="Gender Earnings Disparity" + ), + xaxis=dict( + title=dict( + text="Annual Salary (in thousands)" + ) + ), + yaxis=dict( + title=dict( + text="School" + ) + ), +) fig.show() ``` @@ -139,7 +151,7 @@ fig.add_trace(go.Scatter( fig.update_traces(mode='markers', marker=dict(line_width=1, symbol='circle', size=16)) fig.update_layout( - title="Votes cast for ten lowest voting age population in OECD countries", + title=dict(text="Votes cast for ten lowest voting age population in OECD countries"), xaxis=dict( showgrid=False, showline=True, diff --git a/doc/python/dumbbell-plots.md b/doc/python/dumbbell-plots.md index fa93915eeef..931c31c460b 100644 --- a/doc/python/dumbbell-plots.md +++ b/doc/python/dumbbell-plots.md @@ -89,7 +89,7 @@ fig = go.Figure( color="green", size=10 ) - + ), go.Scatter( x=data["2002"], @@ -99,13 +99,13 @@ fig = go.Figure( marker=dict( color="blue", size=10 - ) + ) ), ] ) fig.update_layout( - title="Life Expectancy in Europe: 1952 and 2002", + title=dict(text="Life Expectancy in Europe: 1952 and 2002"), height=1000, legend_itemclick=False ) @@ -158,16 +158,16 @@ fig = go.Figure( mode="markers+lines", showlegend=False, marker=dict( - symbol="arrow", - color="black", - size=16, - angleref="previous", + symbol="arrow", + color="black", + size=16, + angleref="previous", standoff=8 ) ), go.Scatter( x=data["1952"], - y=countries, + y=countries, name="1952", mode="markers", marker=dict( @@ -189,7 +189,7 @@ fig = go.Figure( ) fig.update_layout( - title="Life Expectancy in Europe: 1952 and 2002", + title=dict(text="Life Expectancy in Europe: 1952 and 2002"), height=1000, legend_itemclick=False ) diff --git a/doc/python/figure-labels.md b/doc/python/figure-labels.md index f687fcda1de..ffd652c3cbe 100644 --- a/doc/python/figure-labels.md +++ b/doc/python/figure-labels.md @@ -90,7 +90,7 @@ fig.show() *New in 5.14* -Set `automargin=True` to allow the title to push the figure margins. With `yref` set to `paper`, `automargin=True` expands the margins to make the title visible, but doesn't push outside the container. With `yref` set to `container`, `automargin=True` expands the margins, but the title doesn't overlap with the plot area, tick labels, and axis titles. +Set `automargin=True` to allow the title to push the figure margins. With `yref` set to `paper`, `automargin=True` expands the margins to make the title visible, but doesn't push outside the container. With `yref` set to `container`, `automargin=True` expands the margins, but the title doesn't overlap with the plot area, tick labels, and axis titles. ```python @@ -145,10 +145,24 @@ fig.add_trace(go.Scatter( )) fig.update_layout( - title="Plot Title", - xaxis_title="X Axis Title", - yaxis_title="Y Axis Title", - legend_title="Legend Title", + title=dict( + text="Plot Title" + ), + xaxis=dict( + title=dict( + text="X Axis Title" + ) + ), + yaxis=dict( + title=dict( + text="Y Axis Title" + ) + ), + legend=dict( + title=dict( + text="Legend Title" + ) + ), font=dict( family="Courier New, monospace", size=18, @@ -197,10 +211,24 @@ fig = go.Figure( ), ], layout=go.Layout( - title="Plot Title", - xaxis=dict(title="X Axis Title"), - yaxis=dict(title="Y Axis Title"), - legend=dict(title="Legend Title"), + title=dict( + text="Plot Title" + ), + xaxis=dict( + title=dict( + text="X Axis Title" + ) + ), + yaxis=dict( + title=dict( + text="Y Axis Title" + ) + ), + legend=dict( + title=dict( + text="Legend Title" + ) + ), font=dict( family="Courier New, monospace", size=18, diff --git a/doc/python/hover-text-and-formatting.md b/doc/python/hover-text-and-formatting.md index 7a1fe873117..068095c69e7 100644 --- a/doc/python/hover-text-and-formatting.md +++ b/doc/python/hover-text-and-formatting.md @@ -131,7 +131,7 @@ df = data.stocks() layout = dict( hoversubplots="axis", - title="Stock Price Changes", + title=dict(text="Stock Price Changes"), hovermode="x", grid=dict(rows=3, columns=1), ) diff --git a/doc/python/legend.md b/doc/python/legend.md index 4d102aba4fe..d9042bb97a8 100644 --- a/doc/python/legend.md +++ b/doc/python/legend.md @@ -492,7 +492,7 @@ fig.add_trace(go.Scatter( line=dict(color="MediumPurple") )) -fig.update_layout(title="Try Clicking on the Legend Items!") +fig.update_layout(title=dict(text="Try Clicking on the Legend Items!")) fig.show() ``` @@ -542,7 +542,7 @@ fig.add_trace(go.Scatter( showlegend=False )) -fig.update_layout(title="Try Clicking on the Legend Items!") +fig.update_layout(title=dict(text="Try Clicking on the Legend Items!")) fig.show() ``` @@ -550,7 +550,7 @@ fig.show() *New in 5.20* -To indent legend entries, set `indenation` on `layout.legend` to a number of pixels. In the following example, we indent legend entries by 10 pixels. +To indent legend entries, set `indenation` on `layout.legend` to a number of pixels. In the following example, we indent legend entries by 10 pixels. ```python import plotly.graph_objects as go @@ -570,7 +570,9 @@ fig = go.Figure( ], layout=dict( legend=dict( - title="Species", + title=dict( + text="Species", + ), indentation=10 ) ), @@ -629,7 +631,7 @@ fig.add_trace(go.Scatter( line=dict(color="MediumPurple") )) -fig.update_layout(title="Try Clicking on the Legend Items!") +fig.update_layout(title=dict(text="Try Clicking on the Legend Items!")) fig.update_layout(legend=dict(groupclick="toggleitem")) fig.show() @@ -727,22 +729,27 @@ fig = go.Figure( ), ], layout=dict( - title="GDP Per Capita", - legend={ - "title": "By country", - "xref": "container", - "yref": "container", - "y": 0.65, - "bgcolor": "Orange", - }, - legend2={ - "title": "By continent", - "xref": "container", - "yref": "container", - "y": 0.85, - "bgcolor": "Gold", - - }, + title=dict( + text="GDP Per Capita" + ), + legend=dict( + title=dict( + text="By country" + ), + xref="container", + yref="container", + y=0.65, + bgcolor="Orange" + ), + legend2=dict( + title=dict( + text="By continent" + ), + xref="container", + yref="container", + y=0.85, + bgcolor="Gold" + ), ), ) @@ -770,7 +777,7 @@ fig = go.Figure( go.Scatter(x=df_uk.year, y=df_uk.gdpPercap, name="UK"), ], layout=dict( - title="GDP Per Capita", + title=dict(text="GDP Per Capita"), legend={ "x": 0.9, "y": 0.9, diff --git a/doc/python/marker-style.md b/doc/python/marker-style.md index f68030e096e..134e2c52a6c 100644 --- a/doc/python/marker-style.md +++ b/doc/python/marker-style.md @@ -352,7 +352,7 @@ fig = go.Figure(go.Scatter(mode="markers", x=namevariants, y=namestems, marker_s marker_line_color="midnightblue", marker_color="lightskyblue", marker_line_width=2, marker_size=15, hovertemplate="name: %{y}%{x}
number: %{marker.symbol}")) -fig.update_layout(title="Mouse over symbols for name & number!", +fig.update_layout(title=dict(text="Mouse over symbols for name & number!"), xaxis_range=[-1,4], yaxis_range=[len(set(namestems)),-1], margin=dict(b=0,r=0), xaxis_side="top", height=1400, width=400) fig.show() @@ -361,7 +361,7 @@ fig.show() ### Using a Custom Marker -To use a custom marker, set the `symbol` on the `marker`. Here we set it to `diamond`. +To use a custom marker, set the `symbol` on the `marker`. Here we set it to `diamond`. ```python @@ -390,10 +390,10 @@ fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species") fig.update_traces( marker=dict( - size=8, - symbol="diamond-open", + size=8, + symbol="diamond-open", line=dict( - width=2, + width=2, # color="DarkSlateGrey" Line colors don't apply to open markers ) ), @@ -465,7 +465,7 @@ fig.show() *New in 5.11* -When you have multiple markers at one location, you can use `standoff` on a marker to move it away from the other marker in the direction of the `angle`. +When you have multiple markers at one location, you can use `standoff` on a marker to move it away from the other marker in the direction of the `angle`. In this example, we set `standoff=8` on the `arrow` marker, which is half the size of the other `circle` marker, meaning it points exactly at the `circle`. ```python @@ -525,7 +525,7 @@ fig = go.Figure( ) fig.update_layout( - title="Population changes 1987 to 2007", + title=dict(text="Population changes 1987 to 2007"), width=1000, height=1000, showlegend=False, diff --git a/doc/python/multiple-axes.md b/doc/python/multiple-axes.md index 5a8deae7e53..b12cc1baa63 100644 --- a/doc/python/multiple-axes.md +++ b/doc/python/multiple-axes.md @@ -282,21 +282,36 @@ fig.add_trace( fig.update_layout( - xaxis=dict(domain=[0.25, 0.75]), + xaxis=dict( + domain=[0.25, 0.75] + ), yaxis=dict( - title="yaxis title", + title=dict( + text="yaxis title" + ) ), yaxis2=dict( - title="yaxis2 title", + title=dict( + text="yaxis2 title" + ), overlaying="y", - side="right", + side="right" + ), + yaxis3=dict( + title=dict( + text="yaxis3 title" + ), + anchor="free", + overlaying="y", + autoshift=True ), - yaxis3=dict(title="yaxis3 title", anchor="free", overlaying="y", autoshift=True), yaxis4=dict( - title="yaxis4 title", + title=dict( + text="yaxis4 title" + ), anchor="free", overlaying="y", - autoshift=True, + autoshift=True ), ) @@ -333,22 +348,37 @@ fig.add_trace( fig.update_layout( - xaxis=dict(domain=[0.25, 0.75]), + xaxis=dict( + domain=[0.25, 0.75] + ), yaxis=dict( - title="yaxis title", + title=dict( + text="yaxis title" + ) ), yaxis2=dict( - title="yaxis2 title", + title=dict( + text="yaxis2 title" + ), overlaying="y", - side="right", + side="right" + ), + yaxis3=dict( + title=dict( + text="yaxis3 title" + ), + anchor="free", + overlaying="y", + autoshift=True ), - yaxis3=dict(title="yaxis3 title", anchor="free", overlaying="y", autoshift=True), yaxis4=dict( - title="yaxis4 title", + title=dict( + text="yaxis4 title" + ), anchor="free", overlaying="y", autoshift=True, - shift=-100, + shift=-100 ), ) diff --git a/doc/python/sankey-diagram.md b/doc/python/sankey-diagram.md index 75fb19db2d7..a014e5a5085 100644 --- a/doc/python/sankey-diagram.md +++ b/doc/python/sankey-diagram.md @@ -151,7 +151,7 @@ fig = go.Figure(data=[go.Sankey( fig.update_layout( hovermode = 'x', - title="Energy forecast for 2050
Source: Department of Energy & Climate Change, Tom Counsell via Mike Bostock", + title=dict(text="Energy forecast for 2050
Source: Department of Energy & Climate Change, Tom Counsell via Mike Bostock"), font=dict(size = 10, color = 'white'), plot_bgcolor='black', paper_bgcolor='black' @@ -264,7 +264,7 @@ fig = go.Figure(go.Sankey( arrowlen=15, source=[0, 0, 1, 2, 5, 4, 3, 5], target=[5, 3, 4, 3, 0, 2, 2, 3], - value=[1, 2, 1, 1, 1, 1, 1, 2] + value=[1, 2, 1, 1, 1, 1, 1, 2] ) )) @@ -275,7 +275,7 @@ fig.show() *New in 5.19* -You can set the alignment of nodes using `node.align`. Here are two examples with the same `source` and `target`. The first example has nodes aligned "left" and the second has nodes aligned "right". `node.align` also supports "center" and "justify". "justify" is the default if `node.align` is not set, and is similar to aligning to the "left", except that nodes without outgoing links are moved to the right of the figure. +You can set the alignment of nodes using `node.align`. Here are two examples with the same `source` and `target`. The first example has nodes aligned "left" and the second has nodes aligned "right". `node.align` also supports "center" and "justify". "justify" is the default if `node.align` is not set, and is similar to aligning to the "left", except that nodes without outgoing links are moved to the right of the figure. ```python import plotly.graph_objects as go @@ -291,7 +291,7 @@ fig = go.Figure(go.Sankey( arrowlen=15, source=[0, 1, 4, 2, 1], target=[1, 4, 5, 4, 3], - value=[4, 2, 3, 1, 2] + value=[4, 2, 3, 1, 2] ) )) @@ -311,7 +311,7 @@ fig = go.Figure(go.Sankey( arrowlen=15, source=[0, 1, 4, 2, 1], target=[1, 4, 5, 4, 3], - value=[4, 2, 3, 1, 2] + value=[4, 2, 3, 1, 2] ) )) diff --git a/doc/python/scatter-plots-on-maps.md b/doc/python/scatter-plots-on-maps.md index fc20d7e5b6a..ece97307817 100644 --- a/doc/python/scatter-plots-on-maps.md +++ b/doc/python/scatter-plots-on-maps.md @@ -144,7 +144,11 @@ fig = go.Figure(data=go.Scattergeo( cmin = 0, color = df['cnt'], cmax = df['cnt'].max(), - colorbar_title="Incoming flights
February 2011" + colorbar=dict( + title=dict( + text="Incoming flights
February 2011" + ) + ) ))) fig.update_layout( diff --git a/doc/python/shapes.md b/doc/python/shapes.md index 23bb514ea46..f14e2e7d3d6 100644 --- a/doc/python/shapes.md +++ b/doc/python/shapes.md @@ -583,7 +583,7 @@ fig.show() *New in 5.23* -When drawing shapes where `xref` or `yref` reference axes of type category or multicategory, you can shift `x0`, `x1`, `y0`, and `y1` away from the center of the category using `x0shift`, `x1shift`, `y0shift`, and `y1shift` by specifying a value between -1 and 1. +When drawing shapes where `xref` or `yref` reference axes of type category or multicategory, you can shift `x0`, `x1`, `y0`, and `y1` away from the center of the category using `x0shift`, `x1shift`, `y0shift`, and `y1shift` by specifying a value between -1 and 1. -1 is the center of the previous category, 0 is the center of the referenced category, and 1 is the center of the next category. @@ -636,9 +636,19 @@ fig = go.Figure( ) fig.update_layout( - title="GDP per Capita in Europe (1972)", - xaxis_title="Country", - yaxis_title="GDP per Capita", + title=dict( + text="GDP per Capita in Europe (1972)" + ), + xaxis=dict( + title=dict( + text="Country" + ) + ), + yaxis=dict( + title=dict( + text="GDP per Capita" + ) + ), ) fig.show() @@ -1074,11 +1084,14 @@ fig = go.Figure( y=df.GOOG, ), layout=go.Layout( - yaxis=dict(title="Price in USD"), + yaxis=dict( + title=dict( + text="Price in USD" + )), newshape=dict( label=dict(texttemplate="Change: %{dy:.2f}") ), - title="Google Share Price 2018/2019", + title=dict(text="Google Share Price 2018/2019"), ), ) @@ -1152,12 +1165,14 @@ fig = go.Figure( name="Apple" ), layout=go.Layout( - yaxis=dict(title="Price in USD"), + yaxis=dict( + title=dict(text="Price in USD"), + ), newshape=dict( showlegend=True, label=dict(texttemplate="Change: %{dy:.2f}") ), - title="Apple Share Price 2018/2019", + title=dict(text="Apple Share Price 2018/2019"), ), ) diff --git a/doc/python/splom.md b/doc/python/splom.md index f2f562e0513..bb9a8a748ed 100644 --- a/doc/python/splom.md +++ b/doc/python/splom.md @@ -325,7 +325,7 @@ fig = go.Figure( fig.update_layout( - title="Iris Data set", + title=dict(text="Iris Data set"), hoversubplots="axis", width=600, height=600, diff --git a/doc/python/templates.md b/doc/python/templates.md index 5a765672ad9..b110b736b1d 100644 --- a/doc/python/templates.md +++ b/doc/python/templates.md @@ -83,13 +83,13 @@ z_data = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/a fig = go.Figure( data=go.Surface(z=z_data.values), layout=go.Layout( - title="Mt Bruno Elevation", + title=dict(text="Mt Bruno Elevation"), width=500, height=500, )) for template in ["plotly", "plotly_white", "plotly_dark", "ggplot2", "seaborn", "simple_white", "none"]: - fig.update_layout(template=template, title="Mt Bruno Elevation: '%s' theme" % template) + fig.update_layout(template=template, title=dict(text="Mt Bruno Elevation: '%s' theme" % template)) fig.show() ``` @@ -146,7 +146,7 @@ large_rockwell_template = dict( ) fig = go.Figure() -fig.update_layout(title="Figure Title", +fig.update_layout(title=dict(text="Figure Title"), template=large_rockwell_template) fig.show() ``` From 034a47b81ef0d8751dc3f89a492e4640fcd611a1 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Wed, 6 Nov 2024 14:32:40 -0500 Subject: [PATCH 3/5] remove z-axis --- doc/python/ml-roc-pr.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/doc/python/ml-roc-pr.md b/doc/python/ml-roc-pr.md index 181e11c5cdb..8c4bd7e40da 100644 --- a/doc/python/ml-roc-pr.md +++ b/doc/python/ml-roc-pr.md @@ -299,11 +299,6 @@ fig.update_layout( scaleanchor='x', scaleratio=1 ), - zaxis=dict( - title=dict( - text='Z AXIS TITLE' - ) - ), width=700, height=500 ) fig.show() From 0768685da852d6619e223de7d493fc8c265975fb Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Wed, 6 Nov 2024 14:52:23 -0500 Subject: [PATCH 4/5] update titles as strings --- doc/python/county-choropleth.md | 9 ++++++++- doc/python/pandas-backend.md | 2 +- doc/python/ternary-contour.md | 4 +++- doc/python/trisurf.md | 6 +++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/doc/python/county-choropleth.md b/doc/python/county-choropleth.md index 935f3f649e0..1e4410db37f 100644 --- a/doc/python/county-choropleth.md +++ b/doc/python/county-choropleth.md @@ -120,7 +120,14 @@ fig = ff.create_choropleth( fips=fips, values=values, scope=['CA', 'AZ', 'Nevada', 'Oregon', ' Idaho'], binning_endpoints=[14348, 63983, 134827, 426762, 2081313], colorscale=colorscale, county_outline={'color': 'rgb(255,255,255)', 'width': 0.5}, round_legend_values=True, - legend_title='Population by County', title='California and Nearby States' + legend=dict( + title=dict( + text='Population by County' + ) + ), + title=dict( + text='California and Nearby States' + ) ) fig.layout.template = None fig.show() diff --git a/doc/python/pandas-backend.md b/doc/python/pandas-backend.md index 2ee28762850..d28503cf988 100644 --- a/doc/python/pandas-backend.md +++ b/doc/python/pandas-backend.md @@ -55,7 +55,7 @@ import pandas as pd pd.options.plotting.backend = "plotly" df = pd.DataFrame(dict(a=[1,3,2], b=[3,2,1])) -fig = df.plot(title="Pandas Backend Example", template="simple_white", +fig = df.plot(title=dict(text="Pandas Backend Example"), template="simple_white", labels=dict(index="time", value="money", variable="option")) fig.update_yaxes(tickprefix="$") fig.show() diff --git a/doc/python/ternary-contour.md b/doc/python/ternary-contour.md index f4409579a41..41e63baf273 100644 --- a/doc/python/ternary-contour.md +++ b/doc/python/ternary-contour.md @@ -76,7 +76,9 @@ fig = ff.create_ternary_contour(np.array([Al, Y, Cu]), enthalpy, ncontours=20, colorscale='Viridis', showscale=True, - title='Mixing enthalpy of ternary alloy') + title=dict( + text='Mixing enthalpy of ternary alloy' + )) fig.show() ``` diff --git a/doc/python/trisurf.md b/doc/python/trisurf.md index df0127d15c2..30a6e0edaa7 100644 --- a/doc/python/trisurf.md +++ b/doc/python/trisurf.md @@ -59,7 +59,7 @@ simplices = tri.simplices fig = ff.create_trisurf(x=x, y=y, z=z, simplices=simplices, - title="Torus", aspectratio=dict(x=1, y=1, z=0.3)) + title=dict(text="Torus"), aspectratio=dict(x=1, y=1, z=0.3)) fig.show() ``` @@ -90,7 +90,7 @@ simplices = tri.simplices fig = ff.create_trisurf(x=x, y=y, z=z, colormap="Portland", simplices=simplices, - title="Mobius Band") + title=dict(text="Mobius Band")) fig.show() ``` @@ -122,7 +122,7 @@ fig = ff.create_trisurf(x=x, y=y, z=z, colormap=['rgb(50, 0, 75)', 'rgb(200, 0, 200)', '#c8dcc8'], show_colorbar=True, simplices=simplices, - title="Boy's Surface") + title=dict(text="Boy's Surface")) fig.show() ``` From e15d722b5f5bf0e18ae2c49e75d3465214b73a60 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Wed, 6 Nov 2024 15:08:24 -0500 Subject: [PATCH 5/5] fix pandas example --- doc/python/pandas-backend.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/pandas-backend.md b/doc/python/pandas-backend.md index d28503cf988..2ee28762850 100644 --- a/doc/python/pandas-backend.md +++ b/doc/python/pandas-backend.md @@ -55,7 +55,7 @@ import pandas as pd pd.options.plotting.backend = "plotly" df = pd.DataFrame(dict(a=[1,3,2], b=[3,2,1])) -fig = df.plot(title=dict(text="Pandas Backend Example"), template="simple_white", +fig = df.plot(title="Pandas Backend Example", template="simple_white", labels=dict(index="time", value="money", variable="option")) fig.update_yaxes(tickprefix="$") fig.show()