From 84c7f4a476f03217071025a1504764fb53891445 Mon Sep 17 00:00:00 2001 From: Aidan Feldman Date: Tue, 22 Apr 2025 11:38:14 -0400 Subject: [PATCH 1/2] Elaborate on difference between Plotly Express and Graph Objects functions --- doc/python/graph-objects.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/python/graph-objects.md b/doc/python/graph-objects.md index 936ea6d6960..fca2c41f2e7 100644 --- a/doc/python/graph-objects.md +++ b/doc/python/graph-objects.md @@ -68,7 +68,9 @@ Note that the figures produced by Plotly Express **in a single function-call** a The figures produced by Plotly Express can always be built from the ground up using graph objects, but this approach typically takes **5-100 lines of code rather than 1**. -Here is a simple example of how to produce the same figure object from the same data, once with Plotly Express and once without. The data in this example is in "long form" but [Plotly Express also accepts data in "wide form"](/python/wide-form/) and the line-count savings from Plotly Express over graph objects are comparable. More complex figures such as [sunbursts](/python/sunburst-charts/), [parallel coordinates](/python/parallel-coordinates-plot/), [facet plots](/python/facet-plots/) or [animations](/python/animations/) require many more lines of figure-specific graph objects code, whereas switching from one representation to another with Plotly Express usually involves changing just a few characters. +Here is a simple example of how to produce the same figure object from the same data, once with Plotly Express and once without. Note that [Plotly Express functions](/python-api-reference/plotly.express.html) like [`px.bar()`](/python/bar-charts/) accept a DataFrame and names of columns as the `x` and `y` arguments, while [Graph Objects functions](/python-api-reference/plotly.graph_objects.html) like [`go.Bar()`](/python/bar-charts/#basic-bar-charts-with-plotlygraphobjects) require the values to be passed to the `x` and `y` as a Series/list. + +The data in this example is in "long form" but [Plotly Express also accepts data in "wide form"](/python/wide-form/) and the line-count savings from Plotly Express over graph objects are comparable. More complex figures such as [sunbursts](/python/sunburst-charts/), [parallel coordinates](/python/parallel-coordinates-plot/), [facet plots](/python/facet-plots/) or [animations](/python/animations/) require many more lines of figure-specific graph objects code, whereas switching from one representation to another with Plotly Express usually involves changing just a few characters. ```python import pandas as pd From 7cafb628c6339be4bec16cebf191f0e44efaebb8 Mon Sep 17 00:00:00 2001 From: Aidan Feldman Date: Tue, 29 Apr 2025 22:21:53 -0400 Subject: [PATCH 2/2] tweaking of Plotly Express vs. Graph Objects wording Co-authored-by: Emily KL <4672118+emilykl@users.noreply.github.com> --- doc/python/graph-objects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/graph-objects.md b/doc/python/graph-objects.md index fca2c41f2e7..878b36d6bfc 100644 --- a/doc/python/graph-objects.md +++ b/doc/python/graph-objects.md @@ -68,7 +68,7 @@ Note that the figures produced by Plotly Express **in a single function-call** a The figures produced by Plotly Express can always be built from the ground up using graph objects, but this approach typically takes **5-100 lines of code rather than 1**. -Here is a simple example of how to produce the same figure object from the same data, once with Plotly Express and once without. Note that [Plotly Express functions](/python-api-reference/plotly.express.html) like [`px.bar()`](/python/bar-charts/) accept a DataFrame and names of columns as the `x` and `y` arguments, while [Graph Objects functions](/python-api-reference/plotly.graph_objects.html) like [`go.Bar()`](/python/bar-charts/#basic-bar-charts-with-plotlygraphobjects) require the values to be passed to the `x` and `y` as a Series/list. +Here is a simple example of how to produce the same figure object from the same data, once with Plotly Express and once without. Note that [Plotly Express functions](/python-api-reference/plotly.express.html) like [`px.bar()`](/python/bar-charts/) can accept a DataFrame as their first argument with column names passed to the `x` and `y` arguments, while [Graph Objects functions](/python-api-reference/plotly.graph_objects.html) like [`go.Bar()`](/python/bar-charts/#basic-bar-charts-with-plotlygraphobjects) require the data values to be passed directly to the `x` and `y` arguments as a tuple, list, NumPy array, or Pandas Series. The data in this example is in "long form" but [Plotly Express also accepts data in "wide form"](/python/wide-form/) and the line-count savings from Plotly Express over graph objects are comparable. More complex figures such as [sunbursts](/python/sunburst-charts/), [parallel coordinates](/python/parallel-coordinates-plot/), [facet plots](/python/facet-plots/) or [animations](/python/animations/) require many more lines of figure-specific graph objects code, whereas switching from one representation to another with Plotly Express usually involves changing just a few characters.