Skip to content

Commit 76a965e

Browse files
set random seed for less build churn
1 parent 99d375c commit 76a965e

26 files changed

+43
-16
lines changed

.github/pull_request_template.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Doc upgrade checklist:
22

3+
- [ ] random seed is set if using random data
34
- [ ] file has been moved from `unconverted/x/y.md` to `x/y.md`
45
- [ ] old boilerplate at top and bottom of file has been removed
56
- [ ] Every example is independently runnable and is optimized for short line count

python/2D-Histogram.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jupyter:
4242
import plotly.graph_objects as go
4343

4444
import numpy as np
45+
np.random.seed(1)
4546

4647
x = np.random.randn(500)
4748
y = np.random.randn(500)+1

python/2d-histogram-contour.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jupyter:
4242
import plotly.graph_objects as go
4343

4444
import numpy as np
45+
np.random.seed(1)
4546

4647
x = np.random.uniform(-1, 1, size=500)
4748
y = np.random.uniform(-1, 1, size=500)

python/3d-axes.md

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ For creating 3D charts, see [this page](https://plot.ly/python/3d-charts/).
4848
```python
4949
import plotly.graph_objects as go
5050
import numpy as np
51+
np.random.seed(1)
5152

5253
N = 70
5354

python/annotated_heatmap.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,12 @@ fig.show()
110110
```python
111111
import plotly.figure_factory as ff
112112
import numpy as np
113+
np.random.seed(1)
113114

114115
z = np.random.randn(20, 20)
115116
z_text = np.around(z, decimals=2) # Only show rounded value (full value on hover)
116117

117-
fig = ff.create_annotated_heatmap(z, annotation_text=z_text, colorscale='Greys',
118+
fig = ff.create_annotated_heatmap(z, annotation_text=z_text, colorscale='Greys',
118119
hoverinfo='z')
119120

120121
# Make text size smaller
@@ -183,7 +184,7 @@ z = [[.8, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, 1.],
183184
# Display element name and atomic mass on hover
184185
hover=[]
185186
for x in range(len(symbol)):
186-
hover.append([i + '<br>' + 'Atomic Mass: ' + str(j)
187+
hover.append([i + '<br>' + 'Atomic Mass: ' + str(j)
187188
for i, j in zip(element[x], atomic_mass[x])])
188189

189190
# Invert Matrices
@@ -208,4 +209,4 @@ For more info on Plotly heatmaps, see: https://plot.ly/python/reference/#heatmap
208209

209210
```python
210211
help(ff.create_annotated_heatmap)
211-
```
212+
```

python/box-plots.md

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ When data are not available as tidy dataframes, it is also possible to use the m
9797
```python
9898
import plotly.graph_objects as go
9999
import numpy as np
100+
np.random.seed(1)
100101

101102
y0 = np.random.randn(50) - 1
102103
y1 = np.random.randn(50) + 1

python/click-events.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jupyter:
4343
import plotly.graph_objects as go
4444

4545
import numpy as np
46+
np.random.seed(1)
4647

4748
x = np.random.rand(100)
4849
y = np.random.rand(100)

python/compare-webgl-svg.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ for increased speed, improved interactivity, and the ability to plot even more d
4848
import plotly.graph_objects as go
4949

5050
import numpy as np
51+
np.random.seed(1)
5152

5253
N = 75000
5354

@@ -103,4 +104,4 @@ fig.show()
103104

104105
For more information see <br>
105106
`Scattergl()` : https://plot.ly/python/reference/#scattergl <br>
106-
`Scatter()` : https://plot.ly/python/reference/#scatter
107+
`Scatter()` : https://plot.ly/python/reference/#scatter

python/custom-buttons.md

+1
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ import plotly.graph_objects as go
258258

259259
# Generate dataset
260260
import numpy as np
261+
np.random.seed(1)
261262

262263
x0 = np.random.normal(2, 0.4, 400)
263264
y0 = np.random.normal(2, 0.4, 400)

python/dendrogram.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Dendrogram plots are commonly used in computational biology to show the clusteri
4646
```python
4747
import plotly.figure_factory as ff
4848
import numpy as np
49+
np.random.seed(1)
4950

5051
X = np.random.rand(15, 12) # 15 samples, with 12 dimensions each
5152
fig = ff.create_dendrogram(X)
@@ -183,4 +184,4 @@ fig.show()
183184

184185
```python
185186
help(ff.create_dendrogram)
186-
```
187+
```

python/distplot.md

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ A histogram, a kde plot and a rug plot are displayed.
7171
```python
7272
import plotly.figure_factory as ff
7373
import numpy as np
74+
np.random.seed(1)
7475

7576
x = np.random.randn(1000)
7677
hist_data = [x]

python/dropdowns.md

+1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ import plotly.graph_objects as go
256256

257257
# Generate dataset
258258
import numpy as np
259+
np.random.seed(1)
259260

260261
x0 = np.random.normal(2, 0.4, 400)
261262
y0 = np.random.normal(2, 0.4, 400)

python/heatmaps.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,14 @@ fig.show()
123123
import plotly.graph_objects as go
124124
import datetime
125125
import numpy as np
126+
np.random.seed(1)
126127

127128
programmers = ['Alex','Nicole','Sara','Etienne','Chelsea','Jody','Marianne']
128129

129130
base = datetime.datetime.today()
130131
dates = base - np.arange(180) * datetime.timedelta(days=1)
131132
z = np.random.poisson(size=(len(programmers), len(dates)))
132-
133+
133134
fig = go.Figure(data=go.Heatmap(
134135
z=z,
135136
x=dates,
@@ -159,4 +160,4 @@ IFrame(src= "https://dash-simple-apps.plotly.host/dash-heatmapplot/code", width=
159160
```
160161

161162
#### Reference
162-
See https://plot.ly/python/reference/#heatmap for more information and chart attribute options!
163+
See https://plot.ly/python/reference/#heatmap for more information and chart attribute options!

python/histograms.md

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ When data are not available as tidy dataframes, it is also possible to use the m
138138
import plotly.graph_objects as go
139139

140140
import numpy as np
141+
np.random.seed(1)
141142

142143
x = np.random.randn(500)
143144

python/images.md

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ fig.show()
149149
import plotly.graph_objects as go
150150

151151
import numpy as np
152+
np.random.seed(1)
152153
from scipy.signal import savgol_filter
153154

154155
# Simulate spectroscopy data

python/line-and-scatter.md

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ import plotly.graph_objects as go
9999

100100
# Create random data with numpy
101101
import numpy as np
102+
np.random.seed(1)
102103

103104
N = 100
104105
random_x = np.linspace(0, 1, N)

python/line-charts.md

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ import plotly.graph_objects as go
9797

9898
# Create random data with numpy
9999
import numpy as np
100+
np.random.seed(1)
100101

101102
N = 100
102103
random_x = np.linspace(0, 1, N)

python/marker-style.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import plotly.graph_objects as go
6262

6363
# Generate example data
6464
import numpy as np
65+
np.random.seed(1)
6566

6667
x = np.random.uniform(low=3, high=6, size=(500,))
6768
y = np.random.uniform(low=3, high=6, size=(500,))
@@ -313,4 +314,4 @@ fig.show()
313314
```
314315

315316
### Reference
316-
See https://plot.ly/python/reference/ for more information and chart attribute options!
317+
See https://plot.ly/python/reference/ for more information and chart attribute options!

python/orca-management.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Now let's create a simple scatter plot with 100 random points of variying color
5353
import plotly.graph_objects as go
5454

5555
import numpy as np
56+
np.random.seed(1)
5657

5758
# Generate scatter plot data
5859
N = 100
@@ -209,4 +210,4 @@ In addition to the `executable` property, the `plotly.io.orca.config` object can
209210

210211

211212
### Saving Configuration Settings
212-
Configuration options can optionally be saved to the `~/.plotly/` directory by calling the `plotly.io.config.save()` method. Saved setting will be automatically loaded at the start of future sessions.
213+
Configuration options can optionally be saved to the `~/.plotly/` directory by calling the `plotly.io.config.save()` method. Saved setting will be automatically loaded at the start of future sessions.

python/random-walk.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The jitter in the data points along the x and y axes are meant to illuminate whe
4747
```python
4848
import plotly.graph_objects as go
4949
import numpy as np
50+
np.random.seed(1)
5051

5152
l = 100
5253
steps = np.random.choice([-1, 1], size=l) + 0.05 * np.random.randn(l) # l steps
@@ -112,7 +113,7 @@ steps = np.random.choice([-1, 1], size=(N, l)) + 0.05 * np.random.standard_norma
112113
position = np.cumsum(steps, axis=1) # integrate all positions by summing steps values along time axis
113114

114115
fig = go.Figure(data=go.Histogram(x=position[:, -1])) # positions at final time step
115-
fig.show()
116+
fig.show()
116117
```
117118

118119
```python
@@ -134,7 +135,7 @@ fig.update_xaxes(title_text='$t$')
134135
fig.update_yaxes(title_text='$l$', col=1)
135136
fig.update_yaxes(title_text='$l^2$', col=2)
136137
fig.update_layout(showlegend=False)
137-
fig.show()
138+
fig.show()
138139
```
139140

140141
#### Advanced Tip

python/shapes.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ fig.show()
462462
import plotly.graph_objects as go
463463

464464
import numpy as np
465+
np.random.seed(1)
465466

466467
# Generate data
467468
x0 = np.random.normal(2, 0.45, 300)
@@ -706,4 +707,4 @@ fig.show()
706707
```
707708

708709
### Reference
709-
See https://plot.ly/python/reference/#layout-shapes for more information and chart attribute options!
710+
See https://plot.ly/python/reference/#layout-shapes for more information and chart attribute options!

python/smoothing.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ import scipy
6565

6666
from scipy import signal
6767

68+
np.random.seed(1)
69+
6870
x = np.linspace(0, 10, 100)
6971
y = np.sin(x)
7072
noise = 2 * np.random.random(len(x)) - 1 # uniformly distributed between -1 and 1
@@ -93,8 +95,8 @@ fig.add_trace(go.Scatter(
9395

9496
fig.add_trace(go.Scatter(
9597
x=x,
96-
y=signal.savgol_filter(y,
97-
53, # window size used for filtering
98+
y=signal.savgol_filter(y,
99+
53, # window size used for filtering
98100
3), # order of fitted polynomial
99101
mode='markers',
100102
marker=dict(

python/static-image-export.md

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Now let's create a simple scatter plot with 100 random points of variying color
7676
```python
7777
import plotly.graph_objects as go
7878
import numpy as np
79+
np.random.seed(1)
7980

8081
N = 100
8182
x = np.random.rand(N)

python/table.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fig = go.Figure(data=[go.Table(
121121
fig.show()
122122
```
123123

124-
#### Alternating Row Colors
124+
#### Alternating Row Colors
125125

126126
```python
127127
import plotly.graph_objects as go
@@ -190,6 +190,7 @@ fig.show()
190190
import plotly.graph_objects as go
191191
from plotly.colors import n_colors
192192
import numpy as np
193+
np.random.seed(1)
193194

194195
colors = n_colors('rgb(255, 200, 200)', 'rgb(200, 0, 0)', 9, colortype='rgb')
195196
a = np.random.randint(low=0, high=9, size=10)
@@ -229,4 +230,4 @@ IFrame(src= "https://dash-simple-apps.plotly.host/dash-tableplot/code", width="1
229230
```
230231

231232
#### Reference
232-
For more information on tables and table attributes see: https://plot.ly/python/reference/#table.
233+
For more information on tables and table attributes see: https://plot.ly/python/reference/#table.

python/violin.md

+1
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ A ridgeline plot ([previously known as Joy Plot](https://serialmentor.com/blog/2
244244
import plotly.graph_objects as go
245245
from plotly.colors import n_colors
246246
import numpy as np
247+
np.random.seed(1)
247248

248249
# 12 sets of normal distributed random data, with increasing mean and standard deviation
249250
data = (np.linspace(1, 2, 12)[:, np.newaxis] * np.random.randn(12, 200) +

python/webgl-vs-svg.md

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import plotly.express as px
5151

5252
import pandas as pd
5353
import numpy as np
54+
np.random.seed(1)
5455

5556
N = 100000
5657

0 commit comments

Comments
 (0)