You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: notebooks/figure-labels.md
+34-67Lines changed: 34 additions & 67 deletions
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,21 @@ jupyter:
6
6
extension: .md
7
7
format_name: markdown
8
8
format_version: '1.1'
9
-
jupytext_version: 1.1.1
9
+
jupytext_version: 1.1.6
10
10
kernelspec:
11
11
display_name: Python 3
12
12
language: python
13
13
name: python3
14
+
language_info:
15
+
codemirror_mode:
16
+
name: ipython
17
+
version: 3
18
+
file_extension: .py
19
+
mimetype: text/x-python
20
+
name: python
21
+
nbconvert_exporter: python
22
+
pygments_lexer: ipython3
23
+
version: 3.7.3
14
24
plotly:
15
25
description: How to set the title, legend-entries, and axis-titles in python.
16
26
display_as: layout_opt
@@ -25,101 +35,58 @@ jupyter:
25
35
thumbnail: thumbnail/labels.jpg
26
36
title: Setting the Title, Legend Entries, and Axis Titles in Python | Examples
27
37
| Plotly
38
+
v4upgrade: true
28
39
---
29
40
30
-
#### New to Plotly?
31
-
Plotly's Python library is free and open source! [Get started](https://plot.ly/python/getting-started/) by downloading the client and [reading the primer](https://plot.ly/python/getting-started/).
32
-
<br>You can set up Plotly to work in [online](https://plot.ly/python/getting-started/#initialization-for-online-plotting) or [offline](https://plot.ly/python/getting-started/#initialization-for-offline-plotting) mode, or in [jupyter notebooks](https://plot.ly/python/getting-started/#start-plotting-online).
33
-
<br>We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/python_cheat_sheet.pdf) (new!) to help you get started!
34
-
35
-
36
-
#### Version Check
37
-
Plotly's Python API is updated frequently. Run pip install plotly --upgrade to update your Plotly version.
38
-
39
41
```python
40
-
import plotly
41
-
plotly.__version__
42
-
```
42
+
import plotly.graph_objects as go
43
43
44
-
```python
45
-
import plotly.plotly as py
46
-
import plotly.graph_objs as go
47
44
48
-
trace1 = go.Scatter(
45
+
fig = go.Figure()
46
+
47
+
fig.add_trace(go.Scatter(
49
48
x=[0, 1, 2, 3, 4, 5, 6, 7, 8],
50
49
y=[0, 1, 2, 3, 4, 5, 6, 7, 8],
51
-
name='Name of Trace 1'
52
-
)
53
-
trace2 = go.Scatter(
50
+
name="Name of Trace 1"
51
+
))
52
+
53
+
54
+
fig.add_trace(go.Scatter(
54
55
x=[0, 1, 2, 3, 4, 5, 6, 7, 8],
55
56
y=[1, 0, 3, 2, 5, 4, 7, 6, 8],
56
-
name='Name of Trace 2'
57
-
)
58
-
data = [trace1, trace2]
59
-
layout = go.Layout(
57
+
name="Name of Trace 2"
58
+
))
59
+
60
+
fig.update_layout(
60
61
title=go.layout.Title(
61
-
text='Plot Title',
62
-
xref='paper',
62
+
text="Plot Title",
63
+
xref="paper",
63
64
x=0
64
65
),
65
66
xaxis=go.layout.XAxis(
66
67
title=go.layout.xaxis.Title(
67
-
text='x Axis',
68
+
text="x Axis",
68
69
font=dict(
69
-
family='Courier New, monospace',
70
+
family="Courier New, monospace",
70
71
size=18,
71
-
color='#7f7f7f'
72
+
color="#7f7f7f"
72
73
)
73
74
)
74
75
),
75
76
yaxis=go.layout.YAxis(
76
77
title=go.layout.yaxis.Title(
77
-
text='y Axis',
78
+
text="y Axis",
78
79
font=dict(
79
-
family='Courier New, monospace',
80
+
family="Courier New, monospace",
80
81
size=18,
81
-
color='#7f7f7f'
82
+
color="#7f7f7f"
82
83
)
83
84
)
84
85
)
85
86
)
86
-
fig = go.Figure(data=data, layout=layout)
87
-
py.iplot(fig, filename='styling-names')
88
-
```
89
-
90
-
#### Dash Example
91
87
92
-
93
-
[Dash](https://plot.ly/products/dash/) is an Open Source Python library which can help you convert plotly figures into a reactive, web-based application. Below is a simple example of a dashboard created using Dash. Its [source code](https://github.com/plotly/simple-example-chart-apps/tree/master/dash-figurelabelsplot) can easily be deployed to a PaaS.
0 commit comments