-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Docs updates for Plotly.py version 6 #4840
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
Changes from 1 commit
Commits
Show all changes
120 commits
Select commit
Hold shift + click to select a range
7770164
add examples using base64
archmoj c2d755e
remove example + make small changes to metadata
LiamConnors d0bc21b
add back correct examples
LiamConnors fb0a5d8
add content for numpy arrays
LiamConnors 49ae498
fix typo
LiamConnors 589d105
rename file
LiamConnors 79afc5c
update titles and link
LiamConnors af1c4a4
fix typo and shorten content
LiamConnors 170d7f9
Update numpy-arrays.md
LiamConnors 7a67f81
merge performance content
LiamConnors f75521c
add intro and restructure svg intro
LiamConnors c895f10
Update webgl-vs-svg.md
LiamConnors 77d7aa3
Update webgl-vs-svg.md
LiamConnors c1e43e7
Update webgl-vs-svg.md
LiamConnors bdfd6af
Update doc/python/webgl-vs-svg.md
LiamConnors 8a3769c
Update doc/python/webgl-vs-svg.md
LiamConnors cf7ac59
change order of dtypes + mention specifying dtype in numpy
LiamConnors 13ecdcc
add v6 changes
LiamConnors 9072028
remove old links
LiamConnors df8e619
add basic draft of v6 changes
LiamConnors 02a9b28
add link to numpy reference docs
LiamConnors ca4fa05
add updated structure + more changes
LiamConnors 229be09
update structure
LiamConnors 430b909
Merge branch 'master' into version-6-migration
LiamConnors f151cc3
update version 6 guide
LiamConnors 84e9e76
add transforms removal
LiamConnors 6c6c27b
Merge branch 'master' into add-base64-docs
LiamConnors 56bb8fc
remove extra webgl examples
LiamConnors cdd7839
shorten webgl content
LiamConnors 9ee6b26
small edits + remove extra example
LiamConnors 1325ac1
rename file
LiamConnors 24021f3
add update to types of series
LiamConnors 5d27f02
Merge branch 'master' into version-6-migration
LiamConnors f60f02c
Merge branch 'version-6-migration' into add-base64-docs
LiamConnors a91abfa
add anywidget update
LiamConnors c9e8630
add anywidget
LiamConnors 2a1f49a
Merge pull request #4769 from plotly/add-base64-docs
LiamConnors 9762699
Merge branch 'master' into version-6-migration
LiamConnors cfce152
Update v6-changes.md
LiamConnors 61c380a
remove pandas series mention
LiamConnors 8aba24c
add datashader
LiamConnors 8581a53
remove datashader page
LiamConnors 9e9d4a3
Update smith-charts.md
LiamConnors 470050c
remove transforms pages
LiamConnors 531fc9b
fix page order
LiamConnors 2cf815b
add dataframe support
LiamConnors f51ff00
update pandas references
LiamConnors 25d0d5a
Update doc/python/v6-changes.md
LiamConnors b4394b1
add transforms note
LiamConnors d9bf3ac
Merge branch 'version-6-migration' of https://github.com/plotly/plotl…
LiamConnors ce9091f
various docs updates
LiamConnors bac2b01
remove dash
LiamConnors fc66ae3
fix typo
LiamConnors c6341c0
reorder content
LiamConnors 2f2e84e
various small docs fixes
LiamConnors a84f754
update starting point text
LiamConnors 593a1ed
Update px-arguments.md
LiamConnors 0a3de82
Merge branch 'master' into version-6-migration
LiamConnors dd42534
add grouped stacked bar chart example
LiamConnors 67c8d46
Merge branch 'version-6-migration' of https://github.com/plotly/plotl…
LiamConnors e4b5d79
Update performance.md
LiamConnors 5c389e5
Merge branch 'master' into version-6-migration
LiamConnors 3c578c1
shorten text
LiamConnors 370fd3b
add note on dataframe support
LiamConnors f0157bb
Merge branch 'master' into version-6-migration
LiamConnors 7e4ec79
8000
add note on dataframe support
LiamConnors 1eeee65
fix issue with code running
LiamConnors 963c5aa
add note on performance
LiamConnors 4a1f120
Update v6-changes.md
LiamConnors 3bd901b
Update doc/python/performance.md
LiamConnors 9c7dc27
Update doc/python/performance.md
LiamConnors 4cdd340
Update doc/python/performance.md
LiamConnors 458a5d4
fix 3d
LiamConnors df65774
Merge branch 'version-6-migration' of https://github.com/plotly/plotl…
LiamConnors 87a5a05
Update doc/python/performance.md
LiamConnors e00b553
Update doc/python/px-arguments.md
LiamConnors 39fdfea
Update doc/python/px-arguments.md
LiamConnors aebdbe5
add note on previous versions
LiamConnors 57f2c71
Merge branch 'version-6-migration' of https://github.com/plotly/plotl…
LiamConnors c5285b4
edit dependencies section
LiamConnors ca84936
update arrays and dtypes text
LiamConnors 062d43c
update example
LiamConnors 79b212a
update example
LiamConnors 2d192e7
link out to Plotly Express arguments page
LiamConnors 2425b0a
Merge branch 'master' into version-6-migration
LiamConnors 070f279
Update doc/python/px-arguments.md
LiamConnors 34af731
Update getting-started.md
LiamConnors a410628
remove known limitation
LiamConnors eaae154
mention modin and cuDF
LiamConnors 8db1fbc
Merge branch 'master' into version-6-migration
LiamConnors 26232a2
Update CHANGELOG.md
LiamConnors 61f695d
Update CHANGELOG.md
LiamConnors 260d6c9
Update CHANGELOG.md
LiamConnors 011eedc
remove mention of version 7 not working
LiamConnors d4bd812
Merge branch 'version-6-migration' of https://github.com/plotly/plotl…
LiamConnors 8a81385
reorg of changelog
LiamConnors 55473a1
Update bar-charts.md
LiamConnors 71a183e
Update doc/python/v6-changes.md
LiamConnors 6096262
Update v6-changes.md
LiamConnors 87339c3
Update CHANGELOG.md
LiamConnors 6fe6a88
Update doc/python/performance.md
LiamConnors 58cda6d
Merge branch 'version-6-migration' of https://github.com/plotly/plotl…
LiamConnors 17148c9
Update performance.md
LiamConnors a6a6f17
Update CHANGELOG.md
LiamConnors e483903
Update CHANGELOG.md
LiamConnors d6716cd
Merge branch 'version-6-migration' of https://github.com/plotly/plotl…
LiamConnors f6654a2
Add back v4 migration
LiamConnors 6f42099
Update LaTeX.md
LiamConnors 306b47f
Update v4-migration.md
LiamConnors 760aabf
Merge branch 'master' into version-6-migration
LiamConnors fe19d81
Update v4-migration.md
LiamConnors 0d056db
Merge branch 'version-6-migration' of https://github.com/plotly/plotl…
LiamConnors fb4ac7e
Update doc/python/v6-changes.md
LiamConnors 1adeae7
Update CHANGELOG.md
LiamConnors 8471804
Merge branch 'version-6-migration' of https://github.com/plotly/plotl…
LiamConnors 7549844
Update doc/python/getting-started.md
LiamConnors d77a0e2
Update doc/python/v6-changes.md
LiamConnors 485a1d8
Update doc/python/performance.md
LiamConnors 45ead3f
remove version pins
LiamConnors 2b8e2ba
Update doc/python/px-arguments.md
LiamConnors File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add back v4 migration
- Loading branch information
commit f6654a281c77f081ace3f01a3dc1a8f8cacb7ae9
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,294 @@ | ||
--- | ||
jupyter: | ||
jupytext: | ||
notebook_metadata_filter: all | ||
text_representation: | ||
extension: .md | ||
format_name: markdown | ||
format_version: '1.1' | ||
jupytext_version: 1.1.1 | ||
kernelspec: | ||
display_name: Python 3 | ||
language: python | ||
name: python3 | ||
language_info: | ||
codemirror_mode: | ||
name: ipython | ||
version: 3 | ||
file_extension: .py | ||
mimetype: text/x-python | ||
name: python | ||
nbconvert_exporter: python | ||
pygments_lexer: ipython3 | ||
version: 3.6.7 | ||
plotly: | ||
description: Migration guide for upgrading from version 3 to version 4 | ||
display_as: file_settings | ||
language: python | ||
layout: base | ||
name: Version 4 Migration Guide | ||
order: 8 | ||
page_type: example_index | ||
permalink: python/v4-migration/ | ||
thumbnail: thumbnail/v4-migration.png | ||
--- | ||
|
||
### Upgrading to Version 4 | ||
|
||
Upgrading to version 4 of `plotly` is a matter of following the instructions in the [Getting Started](/python/getting-started/) guide and reinstalling the packages, subject to the notices below. | ||
|
||
### Getting Help | ||
|
||
If you encounter issues in upgrading from version 3 to version 4, please reach out in our [Community Forum](https://community.plotly.com/c/api/python) or if you've found an issue or regression in version 4, please report a [Github Issue](https://github.com/plotly/plotly.py/issues/new) | ||
|
||
<!-- #region --> | ||
### Online features (`plotly.plotly`) moved to `chart-studio` package | ||
|
||
Prior versions of plotly.py contained functionality for creating figures in both "online" and "offline" modes. In "online" mode figures were uploaded to the Chart Studio cloud (or on-premise) service, whereas in "offline" mode figures were rendered locally. **Version 4 of `plotly` is "offline"-only: all "online" functionality has been removed from the main `plotly` distribution package and moved to the new `chart-studio` distribution package.** | ||
|
||
To migrate version 3 "online" functionality, first install the `chart-studio` package using pip... | ||
|
||
``` | ||
$ pip install chart-studio | ||
``` | ||
|
||
or conda. | ||
|
||
``` | ||
$ conda install -c plotly chart-studio | ||
``` | ||
|
||
Then, update your Python import statements to import "online" functionality from the top-level `chart_studio` package, rather than the top-level `plotly` package. For example. replace | ||
|
||
```python | ||
from plotly.plotly import plot, iplot | ||
``` | ||
|
||
with | ||
|
||
```python | ||
from chart_studio.plotly import plot, iplot | ||
``` | ||
|
||
Similarly, | ||
- Replace **`plotly.api`** with **`chart_studio.api`** | ||
- Replace **`plotly.dashboard_objs`** with **`chart_studio.dashboard_objs`** | ||
- Replace **`plotly.grid_objs`** with **`chart_studio.grid_objs`** | ||
- Replace **`plotly.presentation_objs`** with **`chart_studio.presentation_objs`** | ||
- Replace **`plotly.widgets`** with **`chart_studio.widgets`** | ||
<!-- #endregion --> | ||
|
||
<!-- #region --> | ||
### Offline features (`plotly.offline`) replaced by Renderers framework & HTML export | ||
|
||
Version 4 introduces a new renderers framework that is a generalization of version 3's `plotly.offline.init_notebook_mode` and `plotly.offline.iplot` functions for displaying figures. *This is a non-breaking change*: the `plotly.offline.iplot` function is still available and has been reimplemented on top of the renderers framework, so no changes are required when porting to version 4. Going forward, we recommend using the renderers framework directly. See [Displaying plotly figures](/python/renderers) for more information. | ||
|
||
|
||
In version 3, the `plotly.offline.plot` function was used to export figures to HTML files. In version 4, this function has been reimplemented on top of the new `to_html` and `write_html` functions from the `plotly.io` module. These functions have a slightly more consistent API (see docstrings for details), and going forward we recommend using them directly when performing HTML export. When working with a graph object figure, these functions are also available as the `.to_html` and `.write_html` figure methods. | ||
<!-- #endregion --> | ||
|
||
### New default theme | ||
An updated `"plotly"` theme has been enabled by default in version 4. | ||
|
||
```python | ||
import plotly.graph_objects as go | ||
from plotly.subplots import make_subplots | ||
import pandas as pd | ||
|
||
# Make figure with subplots | ||
fig = make_subplots(rows=1, cols=2, specs=[[{"type": "bar"}, | ||
{"type": "surface"}]]) | ||
|
||
# Add bar traces to subplot (1, 1) | ||
fig.add_trace(go.Bar(y=[2, 1, 3]), row=1, col=1) | ||
fig.add_trace(go.Bar(y=[3, 2, 1]), row=1, col=1) | ||
fig.add_trace(go.Bar(y=[2.5, 2.5, 3.5]), row=1, col=1) | ||
|
||
# Add surface trace to subplot (1, 2) | ||
# Read data from a csv | ||
z_data = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv") | ||
fig.add_surface(z=z_data) | ||
|
||
# Hide legend | ||
fig.update_layout( | ||
showlegend=False, | ||
title_text="Default Theme", | ||
height=500, | ||
width=800, | ||
) | ||
|
||
fig.show() | ||
``` | ||
|
||
You can revert to the version 3 figure appearance by disabling the default theme as follows: | ||
|
||
```python | ||
import plotly.io as pio | ||
pio.templates.default = "none" | ||
|
||
import plotly.graph_objects as go | ||
from plotly.subplots import make_subplots | ||
import pandas as pd | ||
|
||
# Make figure with subplots | ||
fig = make_subplots(rows=1, cols=2, specs=[[{"type": "bar"}, | ||
{"type": "surface"}]]) | ||
|
||
# Add bar traces to subplot (1, 1) | ||
fig.add_trace(go.Bar(y=[2, 1, 3]), row=1, col=1) | ||
fig.add_trace(go.Bar(y=[3, 2, 1]), row=1, col=1) | ||
fig.add_trace(go.Bar(y=[2.5, 2.5, 3.5]), row=1, col=1) | ||
|
||
# Add surface trace to subplot (1, 2) | ||
# Read data from a csv | ||
z_data = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv") | ||
fig.add_surface(z=z_data) | ||
|
||
# Hide legend | ||
fig.update_layout( | ||
showlegend=False, | ||
title_text="Default Theme Disabled", | ||
height=500, | ||
width=800, | ||
) | ||
|
||
fig.show() | ||
``` | ||
|
||
```python | ||
# Restore default theme | ||
pio.templates.default = "plotly" | ||
``` | ||
|
||
See [Theming and templates](/python/templates) for more information on theming in plotly.py version 4. | ||
|
||
### Add trace return value | ||
In version 3, the `add_trace` graph object figure method returned a reference to the newly created trace. This was also the case for the `add_{trace_type}` methods (e.g. `add_scatter`, `add_bar`, etc.). In version 4, these methods return a reference to the calling figure. This change was made to support method chaining of figure operations. For example | ||
|
||
```python | ||
from plotly.subplots import make_subplots | ||
(make_subplots(rows=1, cols=2) | ||
.add_scatter(y=[2, 1, 3], row=1, col=1) | ||
.add_bar(y=[3, 2, 1], row=1, col=2) | ||
.update_layout( | ||
title_text="Figure title", | ||
showlegend=False, | ||
width=800, | ||
height=500, | ||
) | ||
.show()) | ||
``` | ||
|
||
<!-- #region --> | ||
Code that relied on the `add_*` methods to return a reference to the newly created trace will need to be updated to access the trace from the returned figure. This can be done by appending `.data[-1]` to the add trace expression. | ||
|
||
Here is an example of a version 3 code snippet that adds a scatter trace to a figure, assigns the result to a variable named `scatter`, and then modifies the marker size of the scatter trace. | ||
|
||
```python | ||
import plotly.graph_objs as go | ||
fig = go.Figure() | ||
scatter = fig.add_trace(go.Scatter(y=[2, 3, 1])) | ||
scatter.marker.size = 20 | ||
``` | ||
In version 4, this would be replaced with the following: | ||
|
||
```python | ||
import plotly.graph_objects as go | ||
fig = go.Figure() | ||
scatter = fig.add_trace(go.Scatter(y=[2, 3, 1])).data[-1] | ||
scatter.marker.size = 20 | ||
``` | ||
<!-- #endregion --> | ||
|
||
### `make_subplots` updates | ||
The `make_subplots` function has been overhauled to support all trace types and to support the integration of Plotly Express. Here are a few changes to be aware of when porting code that uses `make_subplots` to version 4. | ||
|
||
#### New preferred import location | ||
The preferred import location of the `make_subplots` function is now `plotly.subplots.make_subplots`. For compatibility, this function is still available as `plotly.tools.make_subplots`. | ||
|
||
#### Grid no longer printed by default | ||
When the `print_grid` argument to `make_subplots` is set to `True`, a text representation of the subplot grid is printed by the `make_subplots` function. In version 3, the default value of `print_grid` was `True`. In version 4, the default value of `print_grid` is `False`. | ||
|
||
#### New `row_heights` argument to replace `row_width` | ||
The legacy argument for specifying the relative height of subplot rows was called `row_width`. A new `row_heights` argument has been introduced for this purpose. | ||
|
||
> Note: Although it is not mentioned in the docstring for `plotly.subplots.make_subplots`, the legacy `row_width` argument, with the legacy behavior, is still available in version 4. | ||
|
||
In addition to having a more consistent name, values specified to the new `row_heights` argument properly honor the `start_cell` argument. With the legacy `row_width` argument, the list of heights was always interpreted from the bottom row to the top row, even if `start_cell=="top-left"`. With the new `row_heights` argument, the list of heights is interpreted from top to bottom if `start_cell=="top-left"` and from bottom to top if `start_cell=="bottom-left"`. | ||
|
||
When porting code from `row_width` to `row_heights`, the order of the heights list must be reversed if `start_cell=="top-left"` or `start_cell` was unspecified. | ||
|
||
Here is a version 3 compatible example that uses the `row_width` argument to create a figure with subplots where the top row is twice as tall as the bottom row. | ||
|
||
```python | ||
from plotly.subplots import make_subplots | ||
|
||
fig = make_subplots( | ||
rows=2, cols=1, | ||
row_width=[0.33, 0.67], | ||
start_cell="top-left") | ||
|
||
fig.add_scatter(y=[2, 1, 3], row=1, col=1) | ||
fig.add_bar(y=[2, 3, 1], row=2, col=1) | ||
fig.show() | ||
``` | ||
|
||
And here is the equivalent, version 4 example. Note how the order to the height list is reversed compared to the example above. | ||
|
||
```python | ||
from plotly.subplots import make_subplots | ||
|
||
fig = make_subplots( | ||
rows=2, cols=1, | ||
row_heights=[0.67, 0.33], | ||
start_cell="top-left") | ||
|
||
fig.add_scatter(y=[2, 1, 3], row=1, col=1) | ||
fig.add_bar(y=[2, 3, 1], row=2, col=1) | ||
fig.show() | ||
``` | ||
|
||
#### Implementation of shared axes with `make_subplots` | ||
The implementation of shared axis support in the `make_subplots` function has been simplified. Prior to version 4, shared y-axes were implemented by associating a single `yaxis` object with multiple `xaxis` objects, and vica versa. | ||
|
||
In version 4, every 2D Cartesian subplot has a dedicated x-axis and and a dedicated y-axis. Axes are now "shared" by being linked together using the `matches` axis property. | ||
|
||
For legacy code that makes use of the `make_subplots` and add trace APIs, this change does not require any action on the user's part. However, legacy code that uses `make_subplots` to create a figure with shared axes, and then manipulates the axes directly, may require updates. The output of the `.print_grid` method on a figure created using `make_subplots` can be used to identify which axis objects are associated with each subplot. | ||
|
||
```python | ||
from plotly.subplots import make_subplots | ||
fig = make_subplots(rows=1, cols=2, shared_yaxes=True) | ||
fig.print_grid() | ||
print(fig) | ||
``` | ||
|
||
### Trace UIDs | ||
In version 3, all trace graph objects were copied and assigned a new `uid` property when being added to a `Figure`. In version 4, these `uid` properties are only generated automatically when a trace is added to a `FigureWidget`. When a trace is added to a standard `Figure` graph object the input `uid`, if provided, is accepted as is. | ||
|
||
### Timezones | ||
Prior to version 4, when plotly.py was passed a `datetime` that included a timezone, the `datetime` was automatically converted to UTC. In version 4, this conversion is no longer performed, and `datetime` objects are accepted and displayed in local time. | ||
|
||
<!-- #region --> | ||
### Headless image export on Linux with Xvfb. | ||
In version 4, the static image export logic attempts to automatically detect whether to call the orca image export utility using Xvfb. Xvfb is needed for orca to work in a Linux environment if an X11 display server is not available. By default, Xvfb is used if plotly.py is running on Linux if no X11 display server is detected and `Xvfb` is available on the system `PATH`. | ||
|
||
This new behavior can be disabled by setting the `use_xvfb` orca configuration option to `False` as follows: | ||
|
||
```python | ||
import plotly.io as pio | ||
pio.orca.config.use_xvfb = False | ||
``` | ||
<!-- #endregion --> | ||
|
||
### Removals | ||
|
||
#### fileopt argument removal | ||
The `fileopt` argument to `chart_studio.plotly.plot` has been removed, so in-place modifications to previously published figures are no longer supported. | ||
|
||
#### Legacy online `GraphWidget` | ||
The legacy online-only `GraphWidget` class has been removed. Please use the `plotly.graph_objects.FigureWidget` class instead. See the [Figure Widget Overview](/python/figurewidget/) for more information. | ||
|
||
### Recommended style updates | ||
|
||
#### Import from `graph_objects` instead of `graph_objs` | ||
The legacy `plotly.graph_objs` package has been aliased as `plotly.graph_objects` because the latter is much easier to communicate verbally. The `plotly.graph_objs` package is still available for backward compatibility. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.