Skip to content

Commit e339098

Browse files
committed
Merge branch 'main' into mkdocs-conversion
2 parents eef950e + e693deb commit e339098

File tree

96 files changed

+3655
-468
lines changed

Some content is hidden

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

96 files changed

+3655
-468
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## Unreleased
6+
7+
## [6.3.0] - 2025-08-12
8+
9+
### Updated
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)]
11+
12+
### Added
13+
- 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)]
14+
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+
518
## [6.2.0] - 2025-06-26
619

720
### Added

CITATION.cff

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ authors:
99
- family-names: "Parmer"
1010
given-names: "Chris"
1111
title: "An interactive, open-source, and browser-based graphing library for Python"
12-
version: 5.24.1
12+
version: 6.3.0
1313
doi: 10.5281/zenodo.14503524
14-
date-released: 2024-09-12
14+
date-released: 2025-08-12
1515
url: "https://github.com/plotly/plotly.py"
16+

bin/codegen/datatypes.py

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

1317

1418
def get_typing_type(plotly_type, array_ok=False):
@@ -99,6 +103,7 @@ def build_datatype_py(node):
99103

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

bin/utils.py

Lines changed: 78 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -246,27 +246,10 @@ def update_plotlyjs(plotly_js_version, codedir):
246246

247247

248248
# FIXME: switch to argparse
249-
def update_schema_bundle_from_master():
249+
def update_schema_bundle_from_master(args):
250250
"""Update the plotly.js schema and bundle from master."""
251-
252-
if "--devrepo" in sys.argv:
253-
devrepo = sys.argv[sys.argv.index("--devrepo") + 1]
254-
else:
255-
devrepo = "plotly/plotly.js"
256-
257-
if "--devbranch" in sys.argv:
258-
devbranch = sys.argv[sys.argv.index("--devbranch") + 1]
259-
else:
260-
devbranch = "master"
261-
262-
if "--local" in sys.argv:
263-
local = sys.argv[sys.argv.index("--local") + 1]
264-
else:
265-
local = None
266-
267-
if local is None:
268-
build_info = get_latest_publish_build_info(devrepo, devbranch)
269-
251+
if args.local is None:
252+
build_info = get_latest_publish_build_info(args.devrepo, args.devbranch)
270253
archive_url, bundle_url, schema_url = get_bundle_schema_urls(
271254
build_info["build_num"]
272255
)
@@ -277,14 +260,14 @@ def update_schema_bundle_from_master():
277260
# Update schema in package data
278261
overwrite_schema(schema_url)
279262
else:
280-
# this info could be more informative but
281-
# it doesn't seem as useful in a local context
282-
# and requires dependencies and programming.
263+
# this info could be more informative but it doesn't seem as
264+
# useful in a local context and requires dependencies and
265+
# programming.
283266
build_info = {"vcs_revision": "local", "committer_date": str(time.time())}
284-
devrepo = local
285-
devbranch = ""
267+
args.devrepo = args.local
268+
args.devbranch = ""
286269

287-
archive_uri, bundle_uri, schema_uri = get_bundle_schema_local(local)
270+
archive_uri, bundle_uri, schema_uri = get_bundle_schema_local(args.local)
288271
overwrite_bundle_local(bundle_uri)
289272
overwrite_schema_local(schema_uri)
290273

@@ -295,21 +278,84 @@ def update_schema_bundle_from_master():
295278

296279
# Replace version with bundle url
297280
package_json["dependencies"]["plotly.js"] = (
298-
archive_url if local is None else archive_uri
281+
archive_url if args.local is None else archive_uri
299282
)
300283
with open(package_json_path, "w") as f:
301284
json.dump(package_json, f, indent=2)
302285

303286
# update plotly.js version in _plotlyjs_version
304287
rev = build_info["vcs_revision"]
305288
date = str(build_info["committer_date"])
306-
version = "_".join([devrepo, devbranch, date[:10], rev[:8]])
289+
version = "_".join([args.devrepo, args.devbranch, date[:10], rev[:8]])
307290
overwrite_plotlyjs_version_file(version)
308-
install_js_deps(local)
291+
install_js_deps(args.local)
309292

310293

311-
def update_plotlyjs_dev(codedir):
294+
def update_plotlyjs_dev(args, outdir):
312295
"""Update project to a new development version of plotly.js."""
313296

314-
update_schema_bundle_from_master()
315-
perform_codegen(codedir)
297+
update_schema_bundle_from_master(args)
298+
perform_codegen(outdir)
299+
300+
301+
def parse_args():
302+
"""Parse command-line arguments."""
303+
304+
parser = argparse.ArgumentParser()
305+
subparsers = parser.add_subparsers(dest="cmd", help="Available subcommands")
306+
307+
p_codegen = subparsers.add_parser("codegen", help="generate code")
308+
p_codegen.add_argument(
309+
"--noformat", action="store_true", help="prevent reformatting"
310+
)
311+
312+
subparsers.add_parser("lint", help="lint code")
313+
314+
subparsers.add_parser("format", help="reformat code")
315+
316+
p_update_dev = subparsers.add_parser(
317+
"updateplotlyjsdev", help="update plotly.js for development"
318+
)
319+
p_update_dev.add_argument(
320+
"--devrepo", default="plotly/plotly.js", help="repository"
321+
)
322+
p_update_dev.add_argument("--devbranch", default="master", help="branch")
323+
p_update_dev.add_argument("--local", default=None, help="local path")
324+
325+
subparsers.add_parser("updateplotlyjs", help="update plotly.js")
326+
327+
return parser.parse_args()
328+
329+
330+
def main():
331+
"""Main driver."""
332+
333+
project_root = os.path.dirname(os.path.realpath(__file__))
334+
outdir = os.path.join(project_root, "plotly")
335+
336+
args = parse_args()
337+
338+
if args.cmd == "codegen":
339+
perform_codegen(outdir, noformat=args.noformat)
340+
341+
elif args.cmd == "format":
342+
reformat_code(outdir)
343+
344+
elif args.cmd == "lint":
345+
lint_code(outdir)
346+
347+
elif args.cmd == "updateplotlyjsdev":
348+
update_plotlyjs_dev(args, outdir)
349+
350+
elif args.cmd == "updateplotlyjs":
351+
version = plotly_js_version()
352+
print(version)
353+
update_plotlyjs(version, outdir)
354+
355+
else:
356+
print(f"unknown command {args.cmd}", file=sys.stderr)
357+
sys.exit(1)
358+
359+
360+
if __name__ == "__main__":
361+
main()

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.
@@ -621,6 +621,38 @@ fig.update_yaxes(zeroline=True, zerolinewidth=2, zerolinecolor='LightPink')
621621
fig.show()
622622
```
623623

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

626658
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).

0 commit comments

Comments
 (0)