From 1e54e0cf6d610391e45733548af5bdf98c84bdb0 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Tue, 29 Jul 2025 15:18:15 -0400 Subject: [PATCH] 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')