Skip to content

Commit ad0d0bb

Browse files
authored
Merge pull request #5848 from mmporong/doc-examples-attributeerror
docs: fix examples that raise AttributeError when run as scripts
2 parents fcc3c8e + ab658fb commit ad0d0bb

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎doc/python/3d-mesh.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import plotly.graph_objects as go
4242
import numpy as np
4343

4444
# Download data set from plotly repo
45-
pts = np.loadtxt(np.DataSource().open('https://raw.githubusercontent.com/plotly/datasets/master/mesh_dataset.txt'))
45+
pts = np.loadtxt(np.lib.npyio.DataSource().open('https://raw.githubusercontent.com/plotly/datasets/master/mesh_dataset.txt'))
4646
x, y, z = pts.T
4747

4848
fig = go.Figure(data=[go.Mesh3d(x=x, y=y, z=z, color='lightpink', opacity=0.50)])
@@ -58,7 +58,7 @@ The `alphahull` parameter sets the shape of the mesh. If the value is -1 (defaul
5858
import plotly.graph_objects as go
5959
import numpy as np
6060

61-
pts = np.loadtxt(np.DataSource().open('https://raw.githubusercontent.com/plotly/datasets/master/mesh_dataset.txt'))
61+
pts = np.loadtxt(np.lib.npyio.DataSource().open('https://raw.githubusercontent.com/plotly/datasets/master/mesh_dataset.txt'))
6262
x, y, z = pts.T
6363

6464
fig = go.Figure(data=[go.Mesh3d(x=x, y=y, z=z,

‎doc/python/colorscales.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ fig.show()
443443
```python
444444
import plotly.graph_objects as go
445445

446-
import urllib
446+
import urllib.request
447447
import json
448448

449449
response = urllib.request.urlopen(
@@ -535,7 +535,7 @@ Like axes, you can customize the color bar ticks, labels, and values with `ticks
535535
```python
536536
import plotly.graph_objects as go
537537

538-
import urllib
538+
import urllib.request
539539
import json
540540

541541
# Load heatmap data
@@ -570,7 +570,7 @@ By default, color bars are displayed vertically. You can change a color bar to b
570570
```python
571571
import plotly.graph_objects as go
572572

573-
import urllib
573+
import urllib.request
574574
import json
575575

576576
# Load heatmap data
@@ -647,7 +647,7 @@ See the positioning section of [the figure data structure page](/python/figure-s
647647
```python
648648
import plotly.graph_objects as go
649649

650-
import urllib
650+
import urllib.request
651651
import json
652652

653653
# Load heatmap data

‎doc/python/graphing-multiple-chart-types.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ import plotly.graph_objects as go
173173

174174
# Load data
175175
import json
176-
import urllib
176+
import urllib.request
177177

178178
response = urllib.request.urlopen(
179179
"https://raw.githubusercontent.com/plotly/datasets/master/steepest.json")

‎doc/python/sankey-diagram.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fig.show()
6666

6767
```python
6868
import plotly.graph_objects as go
69-
import urllib, json
69+
import urllib.request, json
7070

7171
url = 'https://raw.githubusercontent.com/plotly/plotly.js/master/test/image/mocks/sankey_energy.json'
7272
response = urllib.request.urlopen(url)
@@ -126,7 +126,7 @@ This example also uses [hovermode](https://plotly.com/python/reference/layout/#l
126126

127127
```python
128128
import plotly.graph_objects as go
129-
import urllib, json
129+
import urllib.request, json
130130

131131
url = 'https://raw.githubusercontent.com/plotly/plotly.js/master/test/image/mocks/sankey_energy.json'
132132
response = urllib.request.urlopen(url)

0 commit comments

Comments
 (0)