Skip to content

Commit 851dcc3

Browse files
authored
Merge pull request #4293 from plotly/docs-update-2
Add back docs changes
2 parents 9ef09a4 + 0ae7596 commit 851dcc3

10 files changed

+94
-61
lines changed

doc/python/3d-scatter-plots.md

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ fig = px.scatter_3d(df, x='sepal_length', y='sepal_width', z='petal_width',
7070

7171
# tight layout
7272
fig.update_layout(margin=dict(l=0, r=0, b=0, t=0))
73+
fig.show()
7374
```
7475

7576
#### 3d scatter plots in Dash

doc/python/colorscales.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,11 @@ Using `labelalias` you can replace some labels on the `colorbar` with alternativ
307307
```python
308308
import plotly.graph_objects as go
309309

310-
import urllib
310+
import urllib.request as request
311311
import json
312312

313313
# Load heatmap data
314-
response = urllib.request.urlopen(
314+
response = request.urlopen(
315315
"https://raw.githubusercontent.com/plotly/datasets/master/custom_heatmap_colorscale.json")
316316
dataset = json.load(response)
317317

doc/python/configuration-options.md

+19-10
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import plotly.graph_objects as go
5353

5454
fig = go.Figure()
5555

56-
config = dict({'scrollZoom': True})
56+
config = {'scrollZoom': True}
5757

5858
fig.add_trace(
5959
go.Scatter(
@@ -244,6 +244,8 @@ fig.add_trace(
244244
y=[1, 3, 1]))
245245

246246
fig.update_layout(modebar_remove=['zoom', 'pan'])
247+
248+
fig.show()
247249
```
248250

249251
### Add optional shape-drawing buttons to modebar
@@ -253,16 +255,19 @@ fig.update_layout(modebar_remove=['zoom', 'pan'])
253255
Some modebar buttons of Cartesian plots are optional and have to be added explicitly, using the `modeBarButtonsToAdd` config attribute. These buttons are used for drawing or erasing shapes. See [the tutorial on shapes and shape drawing](python/shapes#drawing-shapes-on-cartesian-plots) for more details.
254256

255257
```python
256-
import plotly.graph_objects as go
257258
import plotly.express as px
259+
258260
df = px.data.iris()
261+
259262
fig = px.scatter(df, x='petal_width', y='sepal_length', color='species')
263+
260264
fig.update_layout(
261265
dragmode='drawopenpath',
262266
newshape_line_color='cyan',
263267
title_text='Draw a path to separate versicolor and virginica'
264268
)
265-
fig.show(config={'modeBarButtonsToAdd':['drawline',
269+
270+
fig.show(config={'modeBarButtonsToAdd': ['drawline',
266271
'drawopenpath',
267272
'drawclosedpath',
268273
'drawcircle',
@@ -276,10 +281,12 @@ fig.show(config={'modeBarButtonsToAdd':['drawline',
276281
The `layout.modebar.add` attribute can be used instead of the approach used above:
277282

278283
```python
279-
import plotly.graph_objects as go
280284
import plotly.express as px
285+
281286
df = px.data.iris()
287+
282288
fig = px.scatter(df, x='petal_width', y='sepal_length', color='species')
289+
283290
fig.update_layout(
284291
dragmode='drawopenpath',
285292
newshape_line_color='cyan',
@@ -292,6 +299,8 @@ fig.update_layout(
292299
'eraseshape'
293300
]
294301
)
302+
303+
fig.show()
295304
```
296305

297306
### Double-Click Delay
@@ -304,12 +313,12 @@ import plotly.graph_objects as go
304313
config = {'doubleClickDelay': 1000}
305314

306315
fig = go.Figure(go.Bar(
307-
y = [3, 5, 3, 2],
308-
x = ["2019-09-02", "2019-10-10", "2019-11-12", "2019-12-22"],
309-
texttemplate = "%{label}",
310-
textposition = "inside"))
316+
y=[3, 5, 3, 2],
317+
x=["2019-09-02", "2019-10-10", "2019-11-12", "2019-12-22"],
318+
texttemplate="%{label}",
319+
textposition="inside"))
311320

312-
fig.update_layout(xaxis = {'type': 'date'})
321+
fig.update_layout(xaxis={'type': 'date'})
313322

314323
fig.show(config=config)
315324
```
@@ -320,4 +329,4 @@ The same configuration dictionary that you pass to the `config` parameter of the
320329

321330
#### Reference
322331

323-
See config options at https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js#L6
332+
See config options at https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js

doc/python/figure-factory-subplots.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Y, X = np.meshgrid(x, y)
6161
u = -1 - X**2 + Y
6262
v = 1 + X - Y**2
6363

64-
fig2 = ff.create_streamline(x, y, u, v, arrow_scale=.1, name='Steamline')
64+
fig2 = ff.create_streamline(x, y, u, v, arrow_scale=.1, name='Streamline')
6565
```
6666

6767
Edit the figures' x and y axes attributes to create subplots:

doc/python/legend.md

+14-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.3'
9-
jupytext_version: 1.14.5
9+
jupytext_version: 1.14.6
1010
kernelspec:
1111
display_name: Python 3 (ipykernel)
1212
language: python
@@ -580,7 +580,7 @@ fig.show()
580580

581581
By default, all traces appear on one legend. To have multiple legends, specify an alternative legend for a trace using the `legend` property. For a second legend, set `legend="legend2"`. Specify more legends with `legend="legend3"`, `legend="legend4"` and so on.
582582

583-
In this example, the last two scatter traces display on the second legend, "legend2". On the figure's layout, we then position and style this legend to display on the right of the graph below the first legend.
583+
In this example, the last two scatter traces display on the second legend, "legend2". On the figure's layout, we then position and style each legend.
584584

585585

586586
```python
@@ -622,20 +622,25 @@ fig = go.Figure(
622622
],
623623
layout=dict(
624624
title="GDP Per Capita",
625-
legend={"title": "By country", "bgcolor": "Orange",},
625+
legend={
626+
"title": "By country",
627+
"xref": "container",
628+
"yref": "container",
629+
"y": 0.65,
630+
"bgcolor": "Orange",
631+
},
626632
legend2={
627-
"x": 1.155,
628-
"y": 0.55,
629-
"xanchor": "right",
630-
"yanchor": "middle",
633+
"title": "By continent",
634+
"xref": "container",
635+
"yref": "container",
636+
"y": 0.85,
631637
"bgcolor": "Gold",
632-
"title": {"text": "By continent"},
638+
633639
},
634640
),
635641
)
636642

637643
fig.show()
638-
639644
```
640645

641646
### Positioning Legends
@@ -666,7 +671,6 @@ fig = go.Figure(
666671
"xref": "container",
667672
"yref": "container",
668673
"bgcolor": "Gold",
669-
"title": {"text": "By continent"},
670674
},
671675
),
672676
)

doc/python/map-configuration.md

+5-11
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.2'
9-
jupytext_version: 1.3.1
8+
format_version: '1.3'
9+
jupytext_version: 1.14.7
1010
kernelspec:
11-
display_name: Python 3
11+
display_name: Python 3 (ipykernel)
1212
language: python
1313
name: python3
1414
language_info:
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.6.8
23+
version: 3.10.4
2424
plotly:
2525
description: How to configure and style base maps for Choropleths and Bubble Maps.
2626
display_as: maps
@@ -119,9 +119,7 @@ fig.show()
119119

120120
### Map Projections
121121

122-
Geo maps are drawn according to a given map [projection](https://en.wikipedia.org/wiki/Map_projection) that flattens the Earth's roughly-spherical surface into a 2-dimensional space.
123-
124-
The available projections are `'equirectangular'`, `'mercator'`, `'orthographic'`, `'natural earth'`, `'kavrayskiy7'`, `'miller'`, `'robinson'`, `'eckert4'`, `'azimuthal equal area'`, `'azimuthal equidistant'`, `'conic equal area'`, `'conic conformal'`, `'conic equidistant'`, `'gnomonic'`, `'stereographic'`, `'mollweide'`, `'hammer'`, `'transverse mercator'`, `'albers usa'`, `'winkel tripel'`, `'aitoff'` and `'sinusoidal'`.
122+
Geo maps are drawn according to a given map [projection](https://en.wikipedia.org/wiki/Map_projection) that flattens the Earth's roughly-spherical surface into a 2-dimensional space. In the following examples, we show the `'orthographic'` and `'natural earth'` projections, two of the many projection types available. For a full list of available projection types, see the [layout.geo reference documentation](https://plotly.com/python/reference/layout/geo/#layout-geo-projection-type).
125123

126124
```python
127125
import plotly.graph_objects as go
@@ -221,7 +219,3 @@ fig.show()
221219
### Reference
222220

223221
See https://plotly.com/python/reference/layout/geo/ for more information and chart attribute options!
224-
225-
```python
226-
227-
```

doc/python/marker-style.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ fig.show()
326326

327327
The `marker_symbol` attribute allows you to choose from a wide array of symbols to represent markers in your figures.
328328

329-
The basic symbols are: `circle`, `square`, `diamond`, `cross`, `x`, `triangle`, `pentagon`, `hexagram`, `star`, `diamond`, `hourglass`, `bowtie`, `asterisk`, `hash`, `y`, and `line`.
329+
The basic symbols are: `circle`, `square`, `diamond`, `cross`, `x`, `triangle`, `pentagon`, `hexagram`, `star`, `hourglass`, `bowtie`, `asterisk`, `hash`, `y`, and `line`.
330330

331331
Each basic symbol is also represented by a number. Adding 100 to that number is equivalent to appending the suffix "-open" to a symbol name. Adding 200 is equivalent to appending "-dot" to a symbol name. Adding 300 is equivalent to appending "-open-dot" or "dot-open" to a symbol name.
332332

doc/python/shapes.md

+48-21
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.3'
9-
jupytext_version: 1.14.5
9+
jupytext_version: 1.14.6
1010
kernelspec:
1111
display_name: Python 3 (ipykernel)
1212
language: python
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.8.8
23+
version: 3.10.10
2424
plotly:
2525
description: How to make SVG shapes in python. Examples of lines, circle, rectangle,
2626
and path.
@@ -677,12 +677,12 @@ import plotly.graph_objects as go
677677
fig = go.Figure()
678678

679679
fig.add_shape(
680-
type="rect",
681-
fillcolor='turquoise',
682-
x0=1,
683-
y0=1,
684-
x1=2,
685-
y1=3,
680+
type="rect",
681+
fillcolor='turquoise',
682+
x0=1,
683+
y0=1,
684+
x1=2,
685+
y1=3,
686686
label=dict(text="Text in rectangle")
687687
)
688688
fig.add_shape(
@@ -701,8 +701,8 @@ fig.show()
701701

702702
#### Styling Text Labels
703703

704-
Use the `font` property to configure the `color`, `size`, and `family` of the label font.
705-
In this example, we change the label color of the first rectangle to "DarkOrange", set the size of the text above the line to 20, and change the font family and set the font size on the second rectangle.
704+
Use the `font` property to configure the `color`, `size`, and `family` of the label font.
705+
In this example, we change the label color of the first rectangle to "DarkOrange", set the size of the text above the line to 20, and change the font family and set the font size on the second rectangle.
706706

707707
```python
708708
import plotly.graph_objects as go
@@ -776,7 +776,7 @@ fig.add_shape(
776776

777777
fig.add_shape(
778778
type="line",
779-
line_color="MediumSlateBlue",
779+
line_color="MediumSlateBlue",
780780
x0=3,
781781
y0=2,
782782
x1=5,
@@ -870,10 +870,10 @@ fig.show()
870870

871871
#### Setting Label Anchors
872872

873-
`xanchor` sets a label's horizontal positional anchor and `yanchor` sets its vertical position anchor.
873+
`xanchor` sets a label's horizontal positional anchor and `yanchor` sets its vertical position anchor.
874874
Use `xanchor` to bind the `textposition` to the "left", "center" or "right" of the label text and `yanchor` to bind `textposition` to the "top", "middle" or "bottom" of the label text.
875875

876-
In this example, `yanchor`is set to "top", instead of the default of "bottom" for lines, meaning the text displays below the line.
876+
In this example, `yanchor`is set to "top", instead of the default of "bottom" for lines, meaning the text displays below the line.
877877

878878

879879
```python
@@ -917,18 +917,27 @@ fig.show()
917917

918918
*New in 5.15*
919919

920-
Use `texttemplate` to add text with variables to shapes. `texttemplate` uses d3 number and date formatting and supports raw variables, which use the raw data from the shape definition, and some calculated variables. Add a variable with "%{variable}".
920+
Use `texttemplate` to add text with variables to shapes. You have access to raw variables (`x0`, `x1`, `y0`, `y1`), which use raw data values from the shape definition, and the following calculated variables:
921921

922-
This example adds the raw variables `x0` and `y0` to a rectangle and shows the calculated variables `height`, `slope`, and `width` on three other shapes.
922+
- `xcenter`: (x0 + x1) / 2
923+
- `ycenter`: (y0 + y1) / 2
924+
- `dx`: x1 - x0
925+
- `dy`: y1 - y0
926+
- `width`: abs(x1 - x0)
927+
- `height`: abs(y1 - y0)
928+
- `length` (for lines only): sqrt(dx^2 + dy^2)
929+
- `slope`: (y1 - y0) / (x1 - x0)
923930

924-
For a complete list of available variables, see the [Shape Reference Docs](https://plotly.com/python/reference/layout/shapes/).
931+
`texttemplate` supports d3 number and date formatting.
925932

933+
Add a variable with "%{variable}". This example adds the raw variables `x0` and `y0` to a rectangle and shows the calculated variables `height`, `slope`, `length`, and `width` on three other shapes.
926934

927935
```python
928936
import plotly.graph_objects as go
929937

930938
fig = go.Figure()
931939

940+
932941
fig.add_shape(
933942
type="rect",
934943
fillcolor="MediumSlateBlue",
@@ -955,9 +964,12 @@ fig.add_shape(
955964
x0=3,
956965
y0=0.5,
957966
x1=5,
958-
y1=0.8,
967+
y1=1.5,
959968
line_width=3,
960-
label=dict(texttemplate="Slope: %{slope:.3f}", font=dict(size=20)),
969+
label=dict(
970+
texttemplate="Slope of %{slope:.3f} and length of %{length:.3f}",
971+
font=dict(size=20),
972+
),
961973
)
962974
fig.add_shape(
963975
type="rect",
@@ -980,23 +992,38 @@ fig.show()
980992

981993
*New in 5.15*
982994

983-
Use `texttemplate` to add text with variables to new shapes drawn on the graph. This example figure is configured to allow the user to draw lines and automatically labels each line with its slope. Select **Draw line** in the modebar to try it out.
995+
You can also use `texttemplate` to add text with variables to new shapes drawn on the graph.
996+
997+
In this example, we enable drawing lines on the figure by adding `drawline` to `modeBarButtonsToAdd` in `config`. We then define a `texttemplate` for shapes that shows the calculated variable `dy`. Select **Draw line** in the modebar to try it out.
984998

985999
```python
9861000
import plotly.graph_objects as go
1001+
from plotly import data
1002+
1003+
df = data.stocks()
9871004

9881005
fig = go.Figure(
989-
layout=go.Layout(newshape=dict(label=dict(texttemplate="Slope: %{slope:.3f}")))
1006+
data=go.Scatter(
1007+
x=df.date,
1008+
y=df.GOOG,
1009+
),
1010+
layout=go.Layout(
1011+
yaxis=dict(title="Price in USD"),
1012+
newshape=dict(
1013+
label=dict(texttemplate="Change: %{dy:.2f}")
1014+
),
1015+
title="Google Share Price 2018/2019",
1016+
),
9901017
)
9911018

1019+
9921020
fig.show(
9931021
config={
9941022
"modeBarButtonsToAdd": [
9951023
"drawline",
9961024
]
9971025
}
9981026
)
999-
10001027
```
10011028

10021029
### Reference

doc/python/treemaps.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ This example uses the following attributes:
186186
1. [values](https://plotly.com/python/reference/treemap/#treemap-values): sets the values associated with each of the sectors.
187187
2. [textinfo](https://plotly.com/python/reference/treemap/#treemap-textinfo): determines which trace information appear on the graph that can be 'text', 'value', 'current path', 'percent root', 'percent entry', and 'percent parent', or any combination of them.
188188
3. [pathbar](https://plotly.com/python/reference/treemap/#treemap-pathbar): a main extra feature of treemap to display the current path of the visible portion of the hierarchical map. It may also be useful for zooming out of the graph.
189-
4. [branchvalues](https://plotly.com/python/reference/treemap/#treemap-branchvalues): determines how the items in `values` are summed. When set to "total", items in `values` are taken to be value of all its descendants. In the example below Eva = 65, which is equal to 14 + 12 + 10 + 2 + 6 + 6 + 1 + 4.
189+
4. [branchvalues](https://plotly.com/python/reference/treemap/#treemap-branchvalues): determines how the items in `values` are summed. When set to "total", items in `values` are taken to be value of all its descendants. In the example below Eve = 65, which is equal to 14 + 12 + 10 + 2 + 6 + 6 + 1 + 4.
190190
When set to "remainder", items in `values` corresponding to the root and the branches sectors are taken to be the extra part not part of the sum of the values at their leaves.
191191

192192
```python

0 commit comments

Comments
 (0)