Skip to content

Commit 4b6c4be

Browse files
committed
Merge branch 'codegen2' into type-annotations
2 parents e8093f9 + 51911a4 commit 4b6c4be

39 files changed

+443
-546
lines changed

.circleci/config.yml

Lines changed: 128 additions & 209 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
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-
## [6.0.1] - 2025-02-16
5+
## [6.0.1] - 2025-03-14
6+
7+
### Updated
8+
- Updated Plotly.js from version 3.0.0 to version 3.0.1. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#301----2025-02-18) for more information.
9+
610

711
### Fixed
8-
- Fix `TypeError` when using `orjson` to serialize `pandas.NA`.
12+
- Fix `TypeError` when using `orjson` to serialize `pandas.NA` [[#5040](https://github.com/plotly/plotly.py/pull/5040)].
13+
- Fix issue where using `category_orders` on `px.pie` raised `ColumnNotFoundError` [[#5000](https://github.com/plotly/plotly.py/pull/5000)].
14+
- Fix incorrect `DeprecationWarning` shown when creating a `px` chart [[#5080](https://github.com/plotly/plotly.py/pull/5080), [#5086](https://github.com/plotly/plotly.py/pull/5086)]
15+
916

1017
## [6.0.0] - 2025-01-28
1118

RELEASE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ Publishing to PyPI:
7070
### Update documentation site
7171

7272
1. Search for the previous version string in the docs and replace it with the new version string, including but not necessarily limited to the following files:
73-
- `doc/python/getting-started.md`
7473
- `doc/apidoc/conf.py`
7574
- `doc/requirements.txt`
7675
2. `doc-prod` should already have been merged on a regular basis into `main`, but

codegen/datatypes.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,11 @@ def build_datatype_py(node):
103103
)
104104
buffer.write("import copy as _copy\n")
105105

106-
if node.name_property in deprecated_mapbox_traces:
107-
buffer.write(f"from warnings import warn\n")
106+
if (
107+
node.name_property in deprecated_mapbox_traces
108+
or node.name_property == "template"
109+
):
110+
buffer.write(f"import warnings\n")
108111

109112
# Write class definition
110113
buffer.write(
@@ -355,10 +358,22 @@ def __init__(self"""
355358
buffer.write("\n\n")
356359
for subtype_node in subtype_nodes:
357360
name_prop = subtype_node.name_property
358-
buffer.write(
359-
f"""
361+
if datatype_class == "Template" and name_prop == "data":
362+
buffer.write(
363+
f"""
364+
# Template.data contains a 'scattermapbox' key, which causes a
365+
# go.Scattermapbox trace object to be created during validation.
366+
# In order to prevent false deprecation warnings from surfacing,
367+
# we suppress deprecation warnings for this line only.
368+
with warnings.catch_warnings():
369+
warnings.filterwarnings("ignore", category=DeprecationWarning)
370+
self._init_provided('{name_prop}', arg, {name_prop})"""
371+
)
372+
else:
373+
buffer.write(
374+
f"""
360375
self._init_provided('{name_prop}', arg, {name_prop})"""
361-
)
376+
)
362377

363378
### Literals
364379
if literal_nodes:
@@ -382,7 +397,7 @@ def __init__(self"""
382397
if node.name_property in deprecated_mapbox_traces:
383398
buffer.write(
384399
f"""
385-
warn(
400+
warnings.warn(
386401
"*{node.name_property}* is deprecated!"
387402
+ " Use *{node.name_property.replace("mapbox", "map")}* instead."
388403
+ " Learn more at: https://plotly.com/python/mapbox-to-maplibre/",

doc/apidoc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# The short X.Y version
2727
version = ""
2828
# The full version, including alpha/beta/rc tags
29-
release = "6.0.0"
29+
release = "6.0.1"
3030

3131

3232
# -- General configuration ---------------------------------------------------

doc/python/ml-pca.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,6 @@ fig.update_traces(diagonal_visible=False)
136136
fig.show()
137137
```
138138

139-
## PCA analysis in Dash
140-
141-
[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`.
142-
143-
Get started with [the official Dash docs](https://dash.plotly.com/installation) and **learn how to effortlessly [style](https://plotly.com/dash/design-kit/) & [deploy](https://plotly.com/dash/app-manager/) apps like this with <a class="plotly-red" href="https://plotly.com/dash/">Dash Enterprise</a>.**
144-
145-
146-
```python hide_code=true
147-
from IPython.display import IFrame
148-
snippet_url = 'https://python-docs-dash-snippets.herokuapp.com/python-docs-dash-snippets/'
149-
IFrame(snippet_url + 'pca-visualization', width='100%', height=1200)
150-
```
151139

152140
<div style="font-size: 0.9em;"><div style="width: calc(100% - 30px); box-shadow: none; border: thin solid rgb(229, 229, 229);"><div style="padding: 5px;"><div><p><strong>Sign up for Dash Club</strong> → Free cheat sheets plus updates from Chris Parmer and Adam Schroeder delivered to your inbox every two months. Includes tips and tricks, community apps, and deep dives into the Dash architecture.
153141
<u><a href="https://go.plotly.com/dash-club?utm_source=Dash+Club+2022&utm_medium=graphing_libraries&utm_content=inline">Join now</a></u>.</p></div></div></div></div>

doc/python/text-and-annotations.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,66 @@ fig.add_annotation(
782782

783783
fig.show()
784784
```
785+
### Specifying Source Lines or Figure Notes on the Bottom of a Figure
786+
787+
This example shows how to add a note about the data source or interpretation at the bottom of the figure. This example aligns the note in the bottom right corner using the title element and container coordinates and then uses an annotation to add a figure title. A near zero container coordinate is an easy and robust way to put text -- such as a source line or figure note -- at the bottom of a figure. It is easier to specify the bottom of the figure in container coordinates than using paper coordinates, since uncertainty about the size of legends and x-axis labels make the paper coordinate of the bottom of the figure uncertain. Making the y container coordinate very slightly positive avoids cutting off the descending strokes of letters like y, p, and q. Only the title command supports container coordinates, so this example re-purposes the title element to insert the note and re-purposes an annotation element for the title. The top of the figure is typically less cluttered and more predictable than the bottom of the figure, so an annotation with its bottom at a paper y-coordinate slightly greater than 1 is a reasonable title location on many graphs.
788+
789+
```python
790+
import plotly.express as px
791+
df = px.data.iris()
792+
fig.update_layout(
793+
title=dict(text="Note: this is the Plotly title element.",
794+
# keeping this title string short avoids getting the text cut off in small windows
795+
# if you need longer text, consider 1) embedding your graphic on a web page and
796+
# putting the note in the HTML to use the browser's automated word wrap,
797+
# 2) using this approach and also specifying a graph width that shows the whole title,
798+
# or 3) using <BR> tags to wrap the text onto multiple lines
799+
yref="container",
800+
y=0.005,
801+
# The "paper" x-coordinates lets us align this with either the right or left
802+
# edge of the plot region.
803+
# The code to align this flush with the right edge of the plot area is
804+
# predictable and simple.
805+
# Putting the title in the lower left corner, aligned with the left edge of the axis labeling would
806+
# require graph specific coordinate adjustments.
807+
xref="paper",
808+
xanchor="right",
809+
x=1,
810+
font=dict(size=12)),
811+
plot_bgcolor="white",
812+
813+
# We move the legend out of the right margin so the right-aligned note is
814+
# flush with the right most element of the graph.
815+
# Here we put the legend in a corner of the graph region
816+
# because it has consistent coordinates at all screen resolutions.
817+
legend=dict(
818+
yanchor="top",
819+
y=1,
820+
xanchor="right",
821+
x=1,
822+
borderwidth=1)
823+
)
824+
825+
# Insert a title by repurposing an annotation
826+
fig.add_annotation(
827+
yref="paper",
828+
yanchor="bottom",
829+
y=1.025, # y = 1 is the top of the plot area; the top is typically uncluttered, so placing
830+
# the bottom of the title slightly above the graph region works on a wide variety of graphs
831+
text="This title is a Plotly annotation",
832+
833+
# Center the title horizontally over the plot area
834+
xref="paper",
835+
xanchor="center",
836+
x=0.5,
837+
838+
showarrow=False,
839+
font=dict(size=18)
840+
)
841+
842+
fig.show()
843+
```
844+
785845

786846
### Customize Displayed Text with a Text Template
787847

doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
plotly==6.0.0
1+
plotly==6.0.1
22
jupytext==1.16.4
33
jupyter-client<7
44
jupyter

js/package-lock.json

Lines changed: 19 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"dependencies": {
88
"lodash-es": "^4.17.21",
9-
"plotly.js": "3.0.0"
9+
"plotly.js": "3.0.1"
1010
},
1111
"devDependencies": {
1212
"@types/plotly.js": "^2.33.4",

plotly/graph_objs/_choroplethmapbox.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from numpy.typing import NDArray
44
from plotly.basedatatypes import BaseTraceType as _BaseTraceType
55
import copy as _copy
6-
from warnings import warn
6+
import warnings
77

88

99
class Choroplethmapbox(_BaseTraceType):
@@ -1771,7 +1771,7 @@ def __init__(
17711771
self._process_kwargs(**dict(arg, **kwargs))
17721772
self._skip_invalid = False
17731773

1774-
warn(
1774+
warnings.warn(
17751775
"*choroplethmapbox* is deprecated!"
17761776
+ " Use *choroplethmap* instead."
17771777
+ " Learn more at: https://plotly.com/python/mapbox-to-maplibre/",

plotly/graph_objs/_densitymapbox.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from numpy.typing import NDArray
44
from plotly.basedatatypes import BaseTraceType as _BaseTraceType
55
import copy as _copy
6-
from warnings import warn
6+
import warnings
77

88

99
class Densitymapbox(_BaseTraceType):
@@ -1743,7 +1743,7 @@ def __init__(
17431743
self._process_kwargs(**dict(arg, **kwargs))
17441744
self._skip_invalid = False
17451745

1746-
warn(
1746+
warnings.warn(
17471747
"*densitymapbox* is deprecated!"
17481748
+ " Use *densitymap* instead."
17491749
+ " Learn more at: https://plotly.com/python/mapbox-to-maplibre/",

plotly/graph_objs/_figure.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
class Figure(BaseFigure):
8+
89
def __init__(
910
self, data=None, layout=None, frames=None, skip_invalid: bool = False, **kwargs
1011
):

plotly/graph_objs/_figurewidget.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
class FigureWidget(BaseFigureWidget):
8+
89
def __init__(
910
self, data=None, layout=None, frames=None, skip_invalid: bool = False, **kwargs
1011
):

plotly/graph_objs/_scattermapbox.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from numpy.typing import NDArray
44
from plotly.basedatatypes import BaseTraceType as _BaseTraceType
55
import copy as _copy
6-
from warnings import warn
6+
import warnings
77

88

99
class Scattermapbox(_BaseTraceType):
@@ -1730,7 +1730,7 @@ def __init__(
17301730
self._process_kwargs(**dict(arg, **kwargs))
17311731
self._skip_invalid = False
17321732

1733-
warn(
1733+
warnings.warn(
17341734
"*scattermapbox* is deprecated!"
17351735
+ " Use *scattermap* instead."
17361736
+ " Learn more at: https://plotly.com/python/mapbox-to-maplibre/",

plotly/graph_objs/layout/_template.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from numpy.typing import NDArray
44
from plotly.basedatatypes import BaseLayoutHierarchyType as _BaseLayoutHierarchyType
55
import copy as _copy
6+
import warnings
67

78

89
class Template(_BaseLayoutHierarchyType):
@@ -125,7 +126,13 @@ def __init__(
125126
self._skip_invalid = kwargs.pop("skip_invalid", False)
126127
self._validate = kwargs.pop("_validate", True)
127128

128-
self._init_provided("data", arg, data)
129+
# Template.data contains a 'scattermapbox' key, which causes a
130+
# go.Scattermapbox trace object to be created during validation.
131+
# In order to prevent false deprecation warnings from surfacing,
132+
# we suppress deprecation warnings for this line only.
133+
with warnings.catch_warnings():
134+
warnings.filterwarnings("ignore", category=DeprecationWarning)
135+
self._init_provided("data", arg, data)
129136
self._init_provided("layout", arg, layout)
130137
self._process_kwargs(**dict(arg, **kwargs))
131138
self._skip_invalid = False

plotly/offline/_plotlyjs_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# DO NOT EDIT
2-
# This file is generated by the updatebundle setup.py command
3-
__plotlyjs_version__ = "3.0.0"
2+
# This file is generated by the updatebundle commands.py command
3+
__plotlyjs_version__ = "3.0.1"

plotly/package_data/plotly.min.js

Lines changed: 77 additions & 77 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plotly/tools.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ def warning_on_one_line(message, category, filename, lineno, file=None, line=Non
6161

6262
warnings.formatwarning = warning_on_one_line
6363

64-
ipython_core_display = optional_imports.get_module("IPython.core.display")
65-
sage_salvus = optional_imports.get_module("sage_salvus")
66-
6764

6865
### mpl-related tools ###
6966
def mpl_to_plotly(fig, resize=False, strip_style=False, verbose=False):

plotly/validators/_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
class DataValidator(_plotly_utils.basevalidators.BaseDataValidator):
5+
56
def __init__(self, plotly_name="data", parent_name="", **kwargs):
67

78
super().__init__(

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ classifiers = [
3232
"Programming Language :: Python :: 3.10",
3333
"Programming Language :: Python :: 3.11",
3434
"Programming Language :: Python :: 3.12",
35+
"Programming Language :: Python :: 3.13",
3536
"Topic :: Scientific/Engineering :: Visualization",
3637
"License :: OSI Approved :: MIT License"
3738
]
3839
requires-python = ">=3.8"
3940
license = {file="LICENSE.txt"}
40-
version = "6.0.0"
41+
version = "6.0.1"
4142
dependencies = [
4243
"narwhals>=1.15.1",
4344
"packaging"

test_requirements/requirements_310_core.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

test_requirements/requirements_310_optional.txt

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)