Skip to content

Commit 8d86e37

Browse files
author
“mahdis-z”
committed
title alignment
1 parent 032e463 commit 8d86e37

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

python/figure-labels.md

Lines changed: 23 additions & 2 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.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](https://plot.ly/python/reference/#layout-title-xref) from "0" (left) to "1" (right), and [y](https://plot.ly/python/reference/#layout-title-y) sets the y position with respect to [yref](https://plot.ly/python/reference/#layout-title-yref) from "0" (bottom) to "1" (top). Moreover, you can define [xanchor](https://plot.ly/python/reference/#layout-title-xanchor) to `left`,`right`, or `center` for setting the title's horizontal alignment with respect to its x position, and/or [yanchor](https://plot.ly/python/reference/#layout-title-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)