diff --git a/doc/python/3d-mesh.md b/doc/python/3d-mesh.md index 610c8153a9..edec74b624 100644 --- a/doc/python/3d-mesh.md +++ b/doc/python/3d-mesh.md @@ -154,6 +154,8 @@ Whereas the previous example used the default `intensitymode='vertex'`, we plot ```python import plotly.graph_objects as go +import numpy as np + fig = go.Figure(data=[ go.Mesh3d( # 8 vertices of a cube diff --git a/doc/python/axes.md b/doc/python/axes.md index 82dca682b2..98271570a8 100644 --- a/doc/python/axes.md +++ b/doc/python/axes.md @@ -118,7 +118,7 @@ The PX `labels` argument can also be used without a data frame argument: ```python import plotly.express as px -fig = px.bar(df, x=["Apples", "Oranges"], y=[10,20], color=["Here", "There"], +fig = px.bar(x=["Apples", "Oranges"], y=[10,20], color=["Here", "There"], labels=dict(x="Fruit", y="Amount", color="Place") ) fig.show() @@ -460,6 +460,7 @@ Here, `ticklabelstandoff=15` moves the labels 15 pixels further away from the x- ```python import plotly.express as px +import pandas as pd df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv') @@ -487,6 +488,7 @@ To draw the label for the minor tick before each major tick, set `ticklabelindex ```python import plotly.express as px +import pandas as pd df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv') diff --git a/doc/python/box-plots.md b/doc/python/box-plots.md index 244c21106e..1eaec475db 100644 --- a/doc/python/box-plots.md +++ b/doc/python/box-plots.md @@ -448,6 +448,7 @@ fig.show() ```python import plotly.graph_objects as go +import numpy as np x_data = ['Carmelo Anthony', 'Dwyane Wade', 'Deron Williams', 'Brook Lopez', diff --git a/doc/python/creating-and-updating-figures.md b/doc/python/creating-and-updating-figures.md index 694e0d1ae0..b23d69e41b 100644 --- a/doc/python/creating-and-updating-figures.md +++ b/doc/python/creating-and-updating-figures.md @@ -206,6 +206,7 @@ fig.show() The `plotly.subplots.make_subplots()` function produces a graph object figure that is preconfigured with a grid of subplots that traces can be added to. The `add_trace()` function will be discussed more below. ```python +import plotly.graph_objects as go from plotly.subplots import make_subplots fig = make_subplots(rows=1, cols=2) @@ -260,6 +261,7 @@ fig.show() If a figure was created using `plotly.subplots.make_subplots()`, then supplying the `row` and `col` arguments to `add_trace()` can be used to add a trace to a particular subplot. ```python +import plotly.graph_objects as go from plotly.subplots import make_subplots fig = make_subplots(rows=1, cols=2) @@ -274,6 +276,7 @@ This also works for figures created by Plotly Express using the `facet_row` and ```python import plotly.express as px +import plotly.graph_objects as go df = px.data.iris() diff --git a/doc/python/imshow.md b/doc/python/imshow.md index bec3b83de9..ddc9c73d41 100644 --- a/doc/python/imshow.md +++ b/doc/python/imshow.md @@ -5,10 +5,10 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.2' - jupytext_version: 1.4.2 + format_version: '1.3' + jupytext_version: 1.17.2 kernelspec: - display_name: Python 3 + display_name: Python 3 (ipykernel) language: python name: python3 language_info: @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.7.7 + version: 3.12.0 plotly: description: How to display image data in Python with Plotly. display_as: scientific @@ -61,7 +61,7 @@ In order to create a numerical array to be passed to `px.imshow`, you can use a ```python import plotly.express as px from skimage import io -img = io.imread('https://upload.wikimedia.org/wikipedia/commons/thumb/0/00/Crab_Nebula.jpg/240px-Crab_Nebula.jpg') +img = io.imread('https://user-images.githubusercontent.com/72614349/179115668-2630e3e4-3a9f-4c88-9494-3412e606450a.jpg') fig = px.imshow(img) fig.show() ``` @@ -274,6 +274,7 @@ fig.show() ### Displaying an image and the histogram of color values ```python +import plotly.graph_objects as go from plotly.subplots import make_subplots from skimage import data img = data.chelsea() diff --git a/doc/python/network-graphs.md b/doc/python/network-graphs.md index ae47e9923c..c9d85b5aa3 100644 --- a/doc/python/network-graphs.md +++ b/doc/python/network-graphs.md @@ -128,6 +128,8 @@ node_trace.text = node_text #### Create Network Graph ```python +import plotly.graph_objects as go + fig = go.Figure(data=[edge_trace, node_trace], layout=go.Layout( title=dict( diff --git a/doc/python/ohlc-charts.md b/doc/python/ohlc-charts.md index f59228b79c..a11a06970a 100644 --- a/doc/python/ohlc-charts.md +++ b/doc/python/ohlc-charts.md @@ -138,6 +138,8 @@ import plotly.graph_objects as go import pandas as pd from datetime import datetime +df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv') + hovertext=[] for i in range(len(df['AAPL.Open'])): hovertext.append('Open: '+str(df['AAPL.Open'][i])+'
Close: '+str(df['AAPL.Close'][i])) diff --git a/doc/python/plotly-express.md b/doc/python/plotly-express.md index 0aebc72dcc..f3cbf1d81d 100644 --- a/doc/python/plotly-express.md +++ b/doc/python/plotly-express.md @@ -6,7 +6,7 @@ jupyter: extension: .md format_name: markdown format_version: '1.3' - jupytext_version: 1.14.7 + jupytext_version: 1.17.2 kernelspec: display_name: Python 3 (ipykernel) language: python @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.10.4 + version: 3.12.0 plotly: description: Plotly Express is a terse, consistent, high-level API for creating figures. @@ -386,7 +386,7 @@ fig.show() ```python import plotly.express as px from skimage import io -img = io.imread('https://upload.wikimedia.org/wikipedia/commons/thumb/0/00/Crab_Nebula.jpg/240px-Crab_Nebula.jpg') +img = io.imread('https://user-images.githubusercontent.com/72614349/179115668-2630e3e4-3a9f-4c88-9494-3412e606450a.jpg') fig = px.imshow(img) fig.show() ``` diff --git a/doc/python/templates.md b/doc/python/templates.md index b110b736b1..070d8633f3 100644 --- a/doc/python/templates.md +++ b/doc/python/templates.md @@ -389,6 +389,7 @@ Combining themes is also supported by Plotly Express ```python import plotly.io as pio +import plotly.graph_objects as go import plotly.express as px pio.templates["draft"] = go.layout.Template( diff --git a/doc/python/time-series.md b/doc/python/time-series.md index c55ffef7a4..bc3ee71df1 100644 --- a/doc/python/time-series.md +++ b/doc/python/time-series.md @@ -325,7 +325,7 @@ fig.show() ``` ```python -import plotly.graph_objects as go +import plotly.express as px import pandas as pd df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')