You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+21-2
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,31 @@
2
2
All notable changes to this project will be documented in this file.
3
3
This project adheres to [Semantic Versioning](http://semver.org/).
4
4
5
-
6
5
## UNRELEASED
7
6
8
7
### Updated
9
-
- Updated Plotly.js from version 2.24.1 to version 2.24.2. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#2242----2023-06-09) for more information. These changes are reflected in the auto-generated `plotly.graph_objects` module.
- Fixed two issues with px.imshow: [[#4330](https://github.com/plotly/plotly.py/issues/4330)] when facet_col is an earlier dimension than animation_frame for xarrays and [[#4329](https://github.com/plotly/plotly.py/issues/4329)] when facet_col has string coordinates in xarrays [[#4331](https://github.com/plotly/plotly.py/pull/4331)]
12
+
13
+
## [5.16.1] - 2023-08-16
14
+
15
+
### Fixed
16
+
- Fixed issue with necessary columns from complex arguments dropped when interchanging dataframes [[#4324](https://github.com/plotly/plotly.py/pull/4324)]
17
+
18
+
## [5.16.0] - 2023-08-11
19
+
20
+
### Updated
21
+
- Updated Plotly.js from version 2.24.1 to version 2.25.2. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#2252----2023-08-11) for more information. These changes are reflected in the auto-generated `plotly.graph_objects` module. Notable changes include:
22
+
- Add "Equal Earth" projection to geo subplots [[#6670](https://github.com/plotly/plotly.js/pull/6670)],
23
+
with thanks to @apparebit for the contribution!
24
+
- Add options to include legends for shapes and `newshape`[[#6653](https://github.com/plotly/plotly.js/pull/6653)]
10
25
-`px` methods now accept data-frame-like objects that support a [dataframe interchange protocol](https://data-apis.org/dataframe-protocol/latest/index.html), such as polars, vaex, modin etc. This protocol has priority on `to_pandas` call, but will only be used if pandas>=2.0.2 is installed in the environment.
26
+
-`px` methods now accept data-frame-like objects that support a `toPandas()` method, such as Spark DataFrames, or a `to_pandas_df()` method, such as Vaex DataFrames.
27
+
28
+
### Fixed
29
+
- Fixed Pandas performance warning issue caused by multiple `frame.insert`[[#4246](https://github.com/plotly/plotly.py/pull/4246)]
Copy file name to clipboardExpand all lines: doc/python/animations.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ jupyter:
37
37
38
38
Several [Plotly Express](/python/plotly-express/) functions support the creation of animated figures through the `animation_frame` and `animation_group` arguments.
39
39
40
-
Here is an example of an animated scatter plot creating using Plotly Express. Note that you should always fix the `x_range` and `y_range` to ensure that your data remains visible throughout the animation.
40
+
Here is an example of an animated scatter plot created with Plotly Express. Note that you should always fix the `x_range` and `y_range` to ensure that your data remains visible throughout the animation.
Please check out our [Troubleshooting guide](/python/troubleshooting/) if you run into any problems with JupyterLab, particularly if you are using multiple python environments inside Jupyter.
Copy file name to clipboardExpand all lines: doc/python/legend.md
+86-14
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ jupyter:
6
6
extension: .md
7
7
format_name: markdown
8
8
format_version: '1.3'
9
-
jupytext_version: 1.14.6
9
+
jupytext_version: 1.14.7
10
10
kernelspec:
11
11
display_name: Python 3 (ipykernel)
12
12
language: python
@@ -20,7 +20,7 @@ jupyter:
20
20
name: python
21
21
nbconvert_exporter: python
22
22
pygments_lexer: ipython3
23
-
version: 3.10.11
23
+
version: 3.10.4
24
24
plotly:
25
25
description: How to configure and style the legend in Plotly with Python.
26
26
display_as: file_settings
@@ -35,7 +35,7 @@ jupyter:
35
35
36
36
### Trace Types, Legends and Color Bars
37
37
38
-
[Traces](/python/figure-structure) of most types can be optionally associated with a single legend item in the [legend](/python/legend/). Whether or not a given trace appears in the legend is controlled via the `showlegend` attribute. Traces which are their own subplots (see above) do not support this, with the exception of traces of type `pie` and `funnelarea` for which every distinct color represented in the trace gets a separate legend item. Users may show or hide traces by clicking or double-clicking on their associated legend item. Traces that support legend items also support the `legendgroup` attribute, and all traces with the same legend group are treated the same way during click/double-click interactions.
38
+
[Traces](/python/figure-structure) of most types and shapes can be optionally associated with a single legend item in the [legend](/python/legend/). Whether or not a given trace or shape appears in the legend is controlled via the `showlegend` attribute. Traces which are their own subplots (see above) do not support this, with the exception of traces of type `pie` and `funnelarea` for which every distinct color represented in the trace gets a separate legend item. Users may show or hide traces by clicking or double-clicking on their associated legend item. Traces that support legend items and shapes also support the `legendgroup` attribute, and all traces and shapes with the same legend group are treated the same way during click/double-click interactions.
39
39
40
40
The fact that legend items are linked to traces means that when using [discrete color](/python/discrete-color/), a figure must have one trace per color in order to get a meaningful legend. [Plotly Express has robust support for discrete color](/python/discrete-color/) to make this easy.
The `legendrank` attribute of a trace can be used to control its placement within the legend, without regard for its placement in the `data` list.
102
+
If you have shapes that are configured to appear in a legend, these are displayed after all traces:
103
103
104
-
The default `legendrank` for traces is 1000 and ties are broken as described above, meaning that any trace can be pulled up to the top if it is the only one with a legend rank less than 1000 and pushed to the bottom if it is the only one with a rank greater than 1000.
The `legendrank` attribute of a trace or shape can be used to control its placement in the legend.
129
+
The default `legendrank` for traces and shapes is 1000. When all traces and shapes have the same `legendrank`, traces appear in the order they appear in the data, followed by shapes in the order they are defined.
130
+
131
+
Any trace or shape can be pulled up to the top of the legend if it is the only one with a legend rank less than 1000 and pushed to the bottom if it is the only one with a rank greater than 1000.
132
+
133
+
In this example, we add a `legendrank` for each trace and shape, giving the shape the lowest rank so it appears first, and moving the first trace defined to the bottom of the legend by giving it the highest rank.
By default the legend is displayed on Plotly charts with multiple traces, and this can be explicitly set with the `layout.showlegend` attribute:
159
+
By default the legend is displayed on Plotly charts with multiple traces, and this can be explicitly set with the `layout.showlegend` attribute.
120
160
121
161
```python
122
162
import plotly.express as px
@@ -193,7 +233,7 @@ fig.show()
193
233
194
234
*New in 5.11*
195
235
196
-
Set the width of horizontal legend entries by setting `entrywidth`. Here we set it to `70` pixels. Pixels is the default unit for `entrywidth`, but you can set it to be a fraction of the plot width using `entrywidthmode='fraction`.
236
+
Set the width of horizontal legend entries by setting `entrywidth`. Here we set it to `70` pixels. Pixels is the default unit for `entrywidth`, but you can set it to be a fraction of the plot width using `entrywidthmode='fraction'`.
197
237
198
238
```python
199
239
import plotly.express as px
@@ -253,7 +293,30 @@ When creating figures using [graph objects](/python/graph-objects/) without usin
253
293
254
294
#### Legend Item Names
255
295
256
-
Legend items appear per trace, and the legend item name is taken from the trace's `name` attribute.
296
+
For traces, legend items appear per trace, and the legend item name is taken from the trace's `name` attribute.
297
+
298
+
```python
299
+
import plotly.graph_objects as go
300
+
301
+
fig = go.Figure()
302
+
303
+
fig.add_trace(go.Scatter(
304
+
x=[1, 2, 3, 4, 5],
305
+
y=[1, 2, 3, 4, 5],
306
+
name="Positive"
307
+
))
308
+
309
+
fig.add_trace(go.Scatter(
310
+
x=[1, 2, 3, 4, 5],
311
+
y=[5, 4, 3, 2, 1],
312
+
name="Negative"
313
+
))
314
+
315
+
fig.show()
316
+
```
317
+
318
+
By default, for shapes, legend items are disabled. Set `showlegend=True` on a shape for it to display a legend item.
319
+
The name that appears for the shape in the legend is the shape's `name` if it is provided. If no `name` is provided, the shape label's `text` is used. If neither is provided, the legend item appears as "shape \<shape number>". For example, "shape 1".
257
320
258
321
```python
259
322
import plotly.graph_objects as go
@@ -272,6 +335,15 @@ fig.add_trace(go.Scatter(
272
335
name="Negative"
273
336
))
274
337
338
+
fig.add_shape(
339
+
showlegend=True,
340
+
type="rect",
341
+
x0=2,
342
+
x1=4,
343
+
y0=4.5,
344
+
y1=5,
345
+
)
346
+
275
347
fig.show()
276
348
```
277
349
@@ -324,7 +396,7 @@ fig.show()
324
396
325
397
#### Hiding the Trace Initially
326
398
327
-
Traces have a `visible` attribute. If set to `legendonly`, the trace is hidden from the graph implicitly. Click on the name in the legend to display the hidden trace.
399
+
Traces and shapes have a `visible` attribute. If set to `legendonly`, the trace or shape is hidden from the graph implicitly. Click on the name in the legend to display the hidden trace or shape.
328
400
329
401
```python
330
402
import plotly.graph_objects as go
@@ -578,7 +650,7 @@ fig.show()
578
650
579
651
*New in 5.15*
580
652
581
-
By default, all traces appear on one legend. To have multiple legends, specify an alternative legend for a trace using the `legend` property. For a second legend, set `legend="legend2"`. Specify more legends with `legend="legend3"`, `legend="legend4"` and so on.
653
+
By default, all traces and shapes appear on one legend. To have multiple legends, specify an alternative legend for a trace or shape using the `legend` property. For a second legend, set `legend="legend2"`. Specify more legends with `legend="legend3"`, `legend="legend4"` and so on.
582
654
583
655
In this example, the last two scatter traces display on the second legend, "legend2". On the figure's layout, we then position and style each legend.
Copy file name to clipboardExpand all lines: doc/python/px-arguments.md
+10-5
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ jupyter:
35
35
36
36
### Plotly Express works with Column-oriented, Matrix or Geographic Data
37
37
38
-
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which operates on a variety of types of data and produces [easy-to-style figures](/python/styling-plotly-express/).
38
+
[Plotly Express](/python/plotly-express/) is the easy-to-use, high-level interface to Plotly, which [operates on a variety of types of data](/python/px-arguments/) and produces [easy-to-style figures](/python/styling-plotly-express/).
39
39
40
40
Plotly Express provides functions to visualize a variety of types of data. Most functions such as `px.bar` or `px.scatter` expect to operate on column-oriented data of the type you might store in a `DataFrame` (in either "long" or "wide" format, see below). These functions use Pandas internally to process the data, but also accept other types of DataFrames as arguments. See the **Input Data as Non-Pandas DataFrames** section below for more details.
41
41
@@ -170,14 +170,12 @@ fig.show()
170
170
171
171
### Input Data as Non-Pandas `DataFrame`s
172
172
173
-
**New in 5.16**
173
+
*New in 5.15*
174
174
175
-
In the examples above, we've used Pandas DataFrames. You can also provide another type of DataFrame to the `data_frame` argument if that DataFrame has a `to_pandas` method or supports the [Python dataframe interchange protocol](https://data-apis.org/dataframe-protocol/latest/index.html), for example, a [Polars](https://www.pola.rs/) DataFrame.
175
+
In the examples above, we've used Pandas DataFrames. You can also provide another type of DataFrame to the `data_frame` argument if that DataFrame has a `to_pandas` method, for example, a [Polars](https://www.pola.rs/) DataFrame.
176
176
177
177
Plotly Express uses Pandas internally to process the data. When you provide a Non-Pandas DataFrame to the `data_frame` argument of a Plotly Express function, the entire DataFrame is converted to a Pandas DataFrame.
178
178
179
-
If you are using a type of DataFrame that doesn't have a `to_pandas` method, but supports the Python dataframe interchange protocol, you'll need to have Pandas version 2.0.3 or later installed.
180
-
181
179
In this example, we use a Polars DataFrame. If you are using Polars, you'll need to install `pyarrow`, which is used by its [`to_pandas` method](
As of version 5.16, you can also provide another type of DataFrame to the `data_frame` argument if that DataFrame supports the [Python dataframe interchange protocol](https://data-apis.org/dataframe-protocol/latest/index.html), or has a `toPandas` or `to_pandas_df` method.
202
+
203
+
Even if the DataFrame that you are using supports the Python dataframe interchange protocol, you'll need to have Pandas version 2.0.3 or later installed. If you are using an earlier version of Pandas, Plotly Express will look for a `to_pandas`, `toPandas`, and `to_pandas_df` method, and use whichever one is available.
204
+
205
+
201
206
### Input Data as array-like columns: NumPy arrays, lists...
202
207
203
208
`px` arguments can also be array-like objects such as lists, NumPy arrays, in both long-form or wide-form (for certain functions).
0 commit comments