Skip to content

Commit c8bb7f0

Browse files
authored
Merge pull request #182 from plotly/title_alignment_py
title alignment
2 parents fe5e886 + 6d1f80d commit c8bb7f0

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

python/figure-labels.md

+23-2
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.1
9+
jupytext_version: 1.2.1
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.6.8
23+
version: 3.7.3
2424
plotly:
2525
description: How to set the global font, title, legend-entries, and axis-titles
2626
in python.
@@ -66,5 +66,26 @@ fig.update_layout(
6666
fig.show()
6767
```
6868

69+
### Align Plot Title
70+
The following example shows how to align the plot title in [layout.title](https://plot.ly/python/reference/#layout-title). `x` sets the x position with respect to `xref` from "0" (left) to "1" (right), and `y` sets the y position with respect to `yref` from "0" (bottom) to "1" (top). Moreover, you can define `xanchor` to `left`,`right`, or `center` for setting the title's horizontal alignment with respect to its x position, and/or `yanchor` to `top`, `bottom`, or `middle` for setting the title's vertical alignment with respect to its y position.
71+
72+
```python
73+
import plotly.graph_objects as go
74+
75+
fig = go.Figure(go.Scatter(
76+
y=[3, 1, 4],
77+
x=["Mon", "Tue", "Wed"]))
78+
79+
fig.update_layout(
80+
title={
81+
'text': "Plot Title",
82+
'y':0.9,
83+
'x':0.5,
84+
'xanchor': 'center',
85+
'yanchor': 'top'})
86+
87+
fig.show()
88+
```
89+
6990
#### Reference
7091
See https://plot.ly/python/reference/#layout for more information!

0 commit comments

Comments
 (0)