Skip to content

Commit bbde957

Browse files
authored
Merge branch 'plotly:main' into master
2 parents fa26acc + 3d36c65 commit bbde957

File tree

145 files changed

+5098
-904
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+5098
-904
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## Unreleased
66

7+
## [6.3.0] - 2025-08-12
8+
79
### Updated
8-
- Updated Plotly.js from version 3.0.1 to version 3.0.3. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#303----2025-07-23) for more information.
10+
- Updated Plotly.js from version 3.0.1 to version 3.1.0. See the plotly.js [release notes](https://github.com/plotly/plotly.js/releases) for more information. [[#5318](https://github.com/plotly/plotly.py/pull/5318)]
911

1012
### Added
1113
- Exposed `plotly.io.get_chrome()` as a function which can be called from within a Python script. [[#5282](https://github.com/plotly/plotly.py/pull/5282)]
1214

15+
### Fixed
16+
- Resolved issue causing extraneous engine deprecation warnings [[#5287](https://github.com/plotly/plotly.py/pull/5287)], with thanks to @jdbeel for the contribution!
17+
1318
## [6.2.0] - 2025-06-26
1419

1520
### Added

codegen/datatypes.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
"choroplethmapbox",
1111
"densitymapbox",
1212
]
13+
locationmode_traces = [
14+
"choropleth",
15+
"scattergeo",
16+
]
1317

1418

1519
def get_typing_type(plotly_type, array_ok=False):
@@ -100,6 +104,7 @@ def build_datatype_py(node):
100104

101105
if (
102106
node.name_property in deprecated_mapbox_traces
107+
or node.name_property in locationmode_traces
103108
or node.name_property == "template"
104109
):
105110
buffer.write("import warnings\n")
@@ -341,6 +346,27 @@ def __init__(self"""
341346
constructor must be a dict or
342347
an instance of :class:`{class_name}`\"\"\")
343348
349+
"""
350+
)
351+
352+
# Add warning for 'country names' locationmode
353+
if node.name_property in locationmode_traces:
354+
buffer.write(
355+
f"""
356+
if locationmode == "country names" and kwargs.get("_validate"):
357+
warnings.warn(
358+
"The library used by the *country names* `locationmode` option is changing in an upcoming version. "
359+
"Country names in existing plots may not work in the new version. "
360+
"To ensure consistent behavior, consider setting `locationmode` to *ISO-3*.",
361+
DeprecationWarning,
362+
stacklevel=5,
363+
)
364+
365+
"""
366+
)
367+
368+
buffer.write(
369+
f"""
344370
self._skip_invalid = kwargs.pop("skip_invalid", False)
345371
self._validate = kwargs.pop("_validate", True)
346372
"""

codegen/resources/plot-schema.json

Lines changed: 601 additions & 102 deletions
Large diffs are not rendered by default.

doc/apidoc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# The short X.Y version
2525
version = ""
2626
# The full version, including alpha/beta/rc tags
27-
release = "6.2.0"
27+
release = "6.3.0"
2828

2929

3030
# -- General configuration ---------------------------------------------------

doc/python/axes.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.3'
9-
jupytext_version: 1.16.3
9+
jupytext_version: 1.17.2
1010
kernelspec:
1111
display_name: Python 3 (ipykernel)
1212
language: python
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.10.14
23+
version: 3.9.0
2424
plotly:
2525
description: How to adjust axes properties in Python - axes titles, styling and
2626
coloring axes and grid lines, ticks, tick labels and more.
@@ -619,6 +619,38 @@ fig.update_yaxes(zeroline=True, zerolinewidth=2, zerolinecolor='LightPink')
619619
fig.show()
620620
```
621621

622+
##### Controlling Zero Line Layer
623+
624+
*New in 6.3*
625+
626+
By default, zero lines are displayed below traces. Set `zerolinelayer="above traces"` on an axis to display its zero line above traces:
627+
628+
```python
629+
import plotly.graph_objects as go
630+
631+
x = ['A', 'B', 'C', 'D', 'A']
632+
y = [2, 0, 4, -3, 2]
633+
634+
fig = go.Figure(
635+
data=[
636+
go.Scatter(
637+
x=x,
638+
y=y,
639+
fill='toself',
640+
mode='none',
641+
fillcolor='lightpink'
642+
)
643+
],
644+
layout=dict(
645+
yaxis=dict(
646+
zerolinelayer="above traces" # Change to "below traces" to see the difference
647+
),
648+
)
649+
)
650+
651+
fig.show()
652+
```
653+
622654
#### Setting the Range of Axes Manually
623655

624656
The visible x and y axis range can be configured manually by setting the `range` axis property to a list of two values, the lower and upper bound.

doc/python/choropleth-maps.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,16 @@ fig.show()
208208
Plotly comes with two built-in geometries which do not require an external GeoJSON file:
209209

210210
1. USA States
211-
2. Countries as defined in the Natural Earth dataset.
211+
2. Countries
212212

213-
**Note and disclaimer:** cultural (as opposed to physical) features are by definition subject to change, debate and dispute. Plotly includes data from Natural Earth "as-is" and defers to the [Natural Earth policy regarding disputed borders](https://www.naturalearthdata.com/downloads/50m-cultural-vectors/50m-admin-0-countries-2/) which read:
213+
In **Plotly.py 6.3 and later**, the built-in countries geometry is created from the following sources:
214+
- [UN data](https://geoportal.un.org/arcgis/sharing/rest/content/items/d7caaff3ef4b4f7c82689b7c4694ad92/data) for country borders, coastlines, land, and ocean layers.
215+
- Natural Earth data for lakes, rivers, and subunits layers.
214216

215-
> Natural Earth Vector draws boundaries of countries according to defacto status. We show who actually controls the situation on the ground.
217+
In **earlier versions of Plotly.py**, the built-in countries geometry is based on Natural Earth data only. Plotly includes data from Natural Earth "as-is". This dataset draws boundaries of countries according to de facto status. See the [Natural Earth page for more details](https://www.naturalearthdata.com/downloads/50m-cultural-vectors/50m-admin-0-countries-2/).
216218

217219
To use the built-in countries geometry, provide `locations` as [three-letter ISO country codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3).
218220

219-
220221
```python
221222
import plotly.express as px
222223

doc/python/configuration-options.md

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.2'
9-
jupytext_version: 1.4.2
8+
format_version: '1.3'
9+
jupytext_version: 1.17.2
1010
kernelspec:
11-
display_name: Python 3
11+
display_name: Python 3 (ipykernel)
1212
language: python
1313
name: python3
1414
language_info:
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.7.7
23+
version: 3.12.4
2424
plotly:
2525
description: How to set the configuration options of figures using the Plotly
2626
Python graphing library.
@@ -323,6 +323,42 @@ fig.update_layout(xaxis={'type': 'date'})
323323
fig.show(config=config)
324324
```
325325

326+
### Disabling Buttons for Specific Axes
327+
328+
*New in 6.3*
329+
330+
Disabling the zoom in, zoom out, and autoscale buttons for specific axes is supported on cartesian axes using the `modebardisable` attribute. In the following example, the zoom in and zoom out buttons are disabled on the `xaxis`, meaning these buttons only zoom in and out on the `yaxis`. Disable the autoscale button using `modebardisable='autoscale'`. You can also disable the zoom and autoscale buttons using `modebardisable='zoominout+autoscale'`.
331+
332+
```python
333+
import plotly.graph_objects as go
334+
import plotly.data
335+
336+
df = plotly.data.stocks()
337+
338+
fig = go.Figure(
339+
data=[
340+
go.Scatter(
341+
x=df['date'],
342+
y=df['GOOG'],
343+
mode='lines+markers',
344+
name='Google Stock Price'
345+
)
346+
],
347+
layout=go.Layout(
348+
title='Google Stock Price Over Time with Mode Bar Disabled',
349+
xaxis=dict(
350+
title='Date',
351+
# Try zooming in or out using the modebar buttons. These only apply to the yaxis in this exampe.
352+
modebardisable='zoominout'
353+
),
354+
yaxis=dict(
355+
title='Stock Price (USD)',
356+
)
357+
)
358+
)
359+
fig.show()
360+
```
361+
326362
### Configuring Figures in Dash Apps
327363

328364
The same configuration dictionary that you pass to the `config` parameter of the `show()` method can also be passed to the [`config` property of a `dcc.Graph` component](https://dash.plotly.com/dash-core-components/graph).

doc/python/hover-text-and-formatting.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.3'
9-
jupytext_version: 1.16.1
9+
jupytext_version: 1.17.2
1010
kernelspec:
1111
display_name: Python 3 (ipykernel)
1212
language: python
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.10.11
23+
version: 3.12.4
2424
plotly:
2525
description: How to use hover text and formatting in Python with Plotly.
2626
display_as: file_settings
@@ -83,6 +83,57 @@ fig.update_layout(hovermode="x unified")
8383
fig.show()
8484
```
8585

86+
#### Customize Title in Unified Hovermode
87+
88+
*New in 6.3*
89+
90+
Customize the title shown in unified hovermode, by specifing `unifiedhovertitle.text`.
91+
92+
The unified hover title is a template string that supports using variables from the data. Numbers are formatted using d3-format's syntax `%{variable:d3-format}`, for `example \"Price: %{y:$.2f}\"`. Dates are formatted using d3-time-format's syntax `%{variable|d3-time-format}`, for example `\"Day: %{2019-01-01|%A}\"`.
93+
94+
The following example uses `'x unified'` hover and specifies a unified hover title that shows the full weekday, month, day, and year.
95+
96+
```python
97+
import plotly.graph_objects as go
98+
import plotly.express as px
99+
100+
df = px.data.stocks()
101+
102+
fig = go.Figure(
103+
data=[
104+
go.Scatter(
105+
x=df['date'],
106+
y=df['GOOG'],
107+
mode='lines',
108+
name='Google'
109+
),
110+
go.Scatter(
111+
x=df['date'],
112+
y=df['AAPL'],
113+
mode='lines',
114+
name='Apple'
115+
)
116+
],
117+
layout=go.Layout(
118+
title_text="Stock Prices with Custom Unified Hover Title",
119+
hovermode='x unified',
120+
xaxis=dict(
121+
title_text='Date',
122+
unifiedhovertitle=dict(
123+
text='<b>%{x|%A, %B %d, %Y}</b>'
124+
)
125+
),
126+
yaxis=dict(
127+
title_text='Price (USD)',
128+
tickprefix='$'
129+
)
130+
)
131+
)
132+
133+
fig.show()
134+
135+
```
136+
86137
#### Control hovermode with Dash
87138

88139
[Dash](https://plotly.com/dash/) is the best way to build analytical apps in Python using Plotly figures. To run the app below, run `pip install dash`, click "Download" to get the code and run `python app.py`.

doc/python/legend.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.3'
9-
jupytext_version: 1.16.1
9+
jupytext_version: 1.17.2
1010
kernelspec:
1111
display_name: Python 3 (ipykernel)
1212
language: python
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.10.11
23+
version: 3.9.0
2424
plotly:
2525
description: How to configure and style the legend in Plotly with Python.
2626
display_as: file_settings
@@ -254,6 +254,46 @@ fig.update_layout(legend=dict(
254254
fig.show()
255255
```
256256

257+
#### Legend Max Height
258+
259+
*New in 6.3*
260+
261+
By default, a legend can expand to fill up to half of the layout area height for a horizontal legend and the full height for a vertical legend. You can change this by specifying a `maxheight` for the legend. `maxheight` is interpreted as a ratio if it is 1 or less, and as an exact pixel value if it is greater than 1. In the following plot with many legend items, we set `maxheight` to a ratio of 0.10, giving the plot more space.
262+
263+
```python
264+
import plotly.express as px
265+
from plotly import data
266+
267+
df = data.gapminder().query("year==2007 and continent == 'Europe'")
268+
269+
fig = px.scatter(df,
270+
x="gdpPercap",
271+
y="lifeExp",
272+
color="country",
273+
size="pop",
274+
size_max=45,
275+
title="Life Expectancy vs. GDP per Capita in 2007 (by Country)",
276+
labels={"gdpPercap": "GDP per Capita"},
277+
)
278+
279+
fig.update_layout(
280+
xaxis=dict(
281+
side="top"
282+
),
283+
legend=dict(
284+
orientation="h",
285+
yanchor="bottom",
286+
y=-0.35,
287+
xanchor="center",
288+
x=0.5,
289+
maxheight=0.1, # Comment maxheight to see legend take up 0.5 of plotting area
290+
title_text="Country"
291+
),
292+
)
293+
294+
fig.show()
295+
```
296+
257297
#### Styling Legends
258298

259299
Legends support many styling options.

0 commit comments

Comments
 (0)