Skip to content

Commit f326de1

Browse files
authored
Merge pull request #201 from plotly/_new_title_standoff
modifications base on 4.3 defaults
2 parents c815255 + 4f1d48e commit f326de1

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

python/axes.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.1'
9-
jupytext_version: 1.1.6
9+
jupytext_version: 1.2.1
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
@@ -23,8 +23,8 @@ jupyter:
2323
version: 3.7.3
2424
plotly:
2525
description: How to adjust axes properties in python. Includes examples of linear
26-
and logarithmic axes, axes titles, styling and coloring axes and grid lines, and
27-
more.
26+
and logarithmic axes, axes titles, styling and coloring axes and grid lines,
27+
and more.
2828
display_as: file_settings
2929
language: python
3030
layout: base
@@ -222,6 +222,31 @@ fig.update_yaxes(title_text='Value A')
222222
fig.show()
223223
```
224224

225+
### Set axis title position
226+
227+
This example sets `standoff` attribute to cartesian axes to determine the distance between the tick labels and the axis title. Note that the axis title position is always constrained within the margins, so the actual standoff distance is always less than the set or default value. By default [automargin](https://plot.ly/python/setting-graph-size/#automatically-adjust-margins) is `True` in Plotly template for the cartesian axis, so the margins will be pushed to fit the axis title at given standoff distance.
228+
229+
```python
230+
import plotly.graph_objects as go
231+
232+
fig = go.Figure(go.Scatter(
233+
mode = "lines+markers",
234+
y = [4, 1, 3],
235+
x = ["December", "January", "February"]))
236+
237+
fig.update_layout(
238+
xaxis = go.layout.XAxis(
239+
tickangle = 90,
240+
title_text = "Month",
241+
title_font = {"size": 20},
242+
title_standoff = 25),
243+
yaxis = go.layout.YAxis(
244+
title_text = "Temperature",
245+
title_standoff = 25))
246+
247+
fig.show()
248+
```
249+
225250
##### Set axis title font
226251
Here is an example that configures the font family, size, and color for the axis titles in a figure created using Plotly Express.
227252

0 commit comments

Comments
 (0)