Skip to content

Commit 83b8b8a

Browse files
committed
update figure-labels notebook
1 parent d1ac927 commit 83b8b8a

File tree

1 file changed

+34
-67
lines changed

1 file changed

+34
-67
lines changed

notebooks/figure-labels.md

Lines changed: 34 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.1'
9-
jupytext_version: 1.1.1
9+
jupytext_version: 1.1.6
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
1313
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
1424
plotly:
1525
description: How to set the title, legend-entries, and axis-titles in python.
1626
display_as: layout_opt
@@ -25,101 +35,58 @@ jupyter:
2535
thumbnail: thumbnail/labels.jpg
2636
title: Setting the Title, Legend Entries, and Axis Titles in Python | Examples
2737
| Plotly
38+
v4upgrade: true
2839
---
2940

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-
3941
```python
40-
import plotly
41-
plotly.__version__
42-
```
42+
import plotly.graph_objects as go
4343

44-
```python
45-
import plotly.plotly as py
46-
import plotly.graph_objs as go
4744

48-
trace1 = go.Scatter(
45+
fig = go.Figure()
46+
47+
fig.add_trace(go.Scatter(
4948
x=[0, 1, 2, 3, 4, 5, 6, 7, 8],
5049
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(
5455
x=[0, 1, 2, 3, 4, 5, 6, 7, 8],
5556
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(
6061
title=go.layout.Title(
61-
text='Plot Title',
62-
xref='paper',
62+
text="Plot Title",
63+
xref="paper",
6364
x=0
6465
),
6566
xaxis=go.layout.XAxis(
6667
title=go.layout.xaxis.Title(
67-
text='x Axis',
68+
text="x Axis",
6869
font=dict(
69-
family='Courier New, monospace',
70+
family="Courier New, monospace",
7071
size=18,
71-
color='#7f7f7f'
72+
color="#7f7f7f"
7273
)
7374
)
7475
),
7576
yaxis=go.layout.YAxis(
7677
title=go.layout.yaxis.Title(
77-
text='y Axis',
78+
text="y Axis",
7879
font=dict(
79-
family='Courier New, monospace',
80+
family="Courier New, monospace",
8081
size=18,
81-
color='#7f7f7f'
82+
color="#7f7f7f"
8283
)
8384
)
8485
)
8586
)
86-
fig = go.Figure(data=data, layout=layout)
87-
py.iplot(fig, filename='styling-names')
88-
```
89-
90-
#### Dash Example
9187

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.
94-
95-
```python
96-
from IPython.display import IFrame
97-
IFrame(src= "https://dash-simple-apps.plotly.host/dash-figurelabelsplot/", width="100%", height="650px", frameBorder="0")
98-
99-
```
100-
101-
```python
102-
from IPython.display import IFrame
103-
IFrame(src= "https://dash-simple-apps.plotly.host/dash-figurelabelsplot/code", width="100%", height="500px", frameBorder="0")
88+
fig.show()
10489
```
10590

10691
#### Reference
10792
See https://plot.ly/python/reference/#layout for more information!
108-
109-
```python
110-
from IPython.display import display, HTML
111-
112-
display(HTML('<link href="//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Inconsolata|Ubuntu+Mono:400,700" rel="stylesheet" type="text/css" />'))
113-
display(HTML('<link rel="stylesheet" type="text/css" href="http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css">'))
114-
115-
! pip install git+https://github.com/plotly/publisher.git --upgrade
116-
import publisher
117-
publisher.publish(
118-
'labels.ipynb', 'python/figure-labels/', 'Setting the Title, Legend Entries, and Axis Titles in Python | Examples | Plotly',
119-
'How to set the title, legend-entries, and axis-titles in python.',
120-
title = 'Setting the Title, Legend Entries, and Axis Titles in Python | Examples | Plotly',
121-
name = 'Setting the Title, Legend Entries, and Axis Titles',
122-
thumbnail='thumbnail/labels.jpg', language='python',
123-
page_type='example_index', has_thumbnail='false', display_as='layout_opt', order=0.5,
124-
ipynb='~notebook_demo/271')
125-
```

0 commit comments

Comments
 (0)