From 36b21ab6bf132a7824aded390d67d0ff6bd6f35b Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 29 Jul 2025 15:18:15 -0400 Subject: [PATCH 1/2] add missing imports and variable definitions --- doc/python/3d-mesh.md | 2 ++ doc/python/axes.md | 4 +++- doc/python/box-plots.md | 1 + doc/python/creating-and-updating-figures.md | 3 +++ doc/python/imshow.md | 1 + doc/python/network-graphs.md | 2 ++ doc/python/ohlc-charts.md | 2 ++ doc/python/templates.md | 1 + doc/python/time-series.md | 2 +- 9 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/python/3d-mesh.md b/doc/python/3d-mesh.md index 610c8153a90..edec74b6248 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 df8672e0e2e..2739c6fcc42 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 244c21106ef..1eaec475db2 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 694e0d1ae0d..b23d69e41be 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 bec3b83de93..08be73e2985 100644 --- a/doc/python/imshow.md +++ b/doc/python/imshow.md @@ -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 ae47e9923c0..c9d85b5aa31 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 f59228b79c0..a11a06970aa 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/templates.md b/doc/python/templates.md index b110b736b1d..070d8633f35 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 c55ffef7a42..bc3ee71df17 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') From 6da56690138d8d9d82f9f5dc77c87bfe0d017ca7 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Fri, 12 Sep 2025 10:41:23 -0400 Subject: [PATCH 2/2] update links --- doc/python/imshow.md | 10 +++++----- doc/python/plotly-express.md | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/python/imshow.md b/doc/python/imshow.md index 08be73e2985..ddc9c73d410 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() ``` diff --git a/doc/python/plotly-express.md b/doc/python/plotly-express.md index 0aebc72dccf..f3cbf1d81df 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() ```