Skip to content

Add performance doc #4769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Nov 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7770164
add examples using base64
archmoj Jan 9, 2024
c2d755e
remove example + make small changes to metadata
LiamConnors Sep 17, 2024
d0bc21b
add back correct examples
LiamConnors Sep 17, 2024
fb0a5d8
add content for numpy arrays
LiamConnors Sep 18, 2024
49ae498
fix typo
LiamConnors Sep 19, 2024
589d105
rename file
LiamConnors Sep 19, 2024
79afc5c
update titles and link
LiamConnors Sep 19, 2024
af1c4a4
fix typo and shorten content
LiamConnors Sep 19, 2024
170d7f9
Update numpy-arrays.md
LiamConnors Sep 19, 2024
7a67f81
merge performance content
LiamConnors Sep 23, 2024
f75521c
add intro and restructure svg intro
LiamConnors Sep 23, 2024
c895f10
Update webgl-vs-svg.md
LiamConnors Sep 23, 2024
77d7aa3
Update webgl-vs-svg.md
LiamConnors Oct 3, 2024
c1e43e7
Update webgl-vs-svg.md
LiamConnors Oct 3, 2024
bdfd6af
Update doc/python/webgl-vs-svg.md
LiamConnors Oct 3, 2024
8a3769c
Update doc/python/webgl-vs-svg.md
LiamConnors Oct 3, 2024
cf7ac59
change order of dtypes + mention specifying dtype in numpy
LiamConnors Oct 10, 2024
02a9b28
add link to numpy reference docs
LiamConnors Oct 22, 2024
6c6c27b
Merge branch 'master' into add-base64-docs
LiamConnors Nov 1, 2024
56bb8fc
remove extra webgl examples
LiamConnors Nov 4, 2024
cdd7839
shorten webgl content
LiamConnors Nov 4, 2024
9ee6b26
small edits + remove extra example
LiamConnors Nov 4, 2024
1325ac1
rename file
LiamConnors Nov 4, 2024
24021f3
add update to types of series
LiamConnors Nov 4, 2024
f60f02c
Merge branch 'version-6-migration' into add-base64-docs
LiamConnors Nov 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions doc/python/webgl-vs-svg.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.16.3
jupytext_version: 1.16.4
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand All @@ -20,9 +20,9 @@ jupyter:
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.10.0
version: 3.11.10
plotly:
description: Using WebGL and NumPy arrays for increased speed, improved interactivity,
description: Using WebGL and NumPy and Pandas for increased speed, improved interactivity,
and the ability to plot even more data!
display_as: basic
language: python
Expand All @@ -34,19 +34,15 @@ jupyter:
thumbnail: thumbnail/webgl.jpg
---

In some examples in the documentation, you'll see figures created using data structures that are native to Python, such as lists and tuples, and which use trace types that render as SVGs.

This will work fine for many use cases, but may not provide optimal performance with larger datasets.

For improved performance, consider using WebGL-based traces and NumPy arrays.
For improved performance, consider using WebGL-based traces and Pandas or NumPy objects.

<!-- #region -->
## WebGL

`plotly` figures are rendered by web browsers, which broadly speaking have two families of capabilities for rendering graphics:
`plotly` figures are rendered by web browsers, which broadly speaking have two families of capabilities for rendering graphics:

- The SVG API, which supports vector rendering
- The Canvas API, which supports raster rendering, and can exploit GPU hardware acceleration via a browser technology known as WebGL.
- The SVG API, which supports vector rendering
- The Canvas API, which supports raster rendering, and can exploit GPU hardware acceleration via a browser technology known as WebGL.


Each `plotly` trace type is primarily rendered with either SVG or WebGL, although WebGL-powered traces also use some SVG. The following trace types use WebGL for part or all of the rendering:
Expand Down Expand Up @@ -212,15 +208,15 @@ fig.show()

See https://plotly.com/python/reference/scattergl/ for more information and chart attribute options!

## NumPy Arrays
## Pandas and NumPy for Improved Performance

Improve the performance of generating Plotly figures that use a large number of data points by using NumPy arrays and other objects that can be converted to NumPy arrays, such as Pandas Series and Index objects.

Plotly.py uses Plotly.js for rendering, which supports typed arrays. In Plotly.py, NumPy array and NumPy-convertible arrays are base64 encoded before being passed to Plotly.js for rendering.

### Arrays and Data Types Supported

The following types of array objects in Python are supported:
The following types of objects in Python are supported for improved performance:

- Numpy `numpy.ndarray` objects.
- Pandas Index, `pandas.Index`, or Series, `pandas.Series`, objects.
Expand Down