diff --git a/CHANGELOG.md b/CHANGELOG.md index 3844a7e2c4..ccc184c23a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Fix issue where user-specified `color_continuous_scale` was ignored when template had `autocolorscale=True` [[#5439](https://github.com/plotly/plotly.py/pull/5439)], with thanks to @antonymilne for the contribution! - Use presence of `COLAB_NOTEBOOK_ID` env var to enable Colab renderer instead of testing import of `google.colab` [[#5473](https://github.com/plotly/plotly.py/pull/5473)], with thanks to @kevineger for the contribution! - Update tests to be compatible with numpy 2.4 [[#5522](https://github.com/plotly/plotly.py/pull/5522)], with thanks to @thunze for the contribution! +- Add default headers to be passed in to Kaleido v1.3.0 to avoid blocked Open Street Map tiles [#5588](https://github.com/plotly/plotly.py/pull/5588)] ### Updated - The `__eq__` method for `graph_objects` classes now returns `NotImplemented` to give the other operand an opportunity to handle the comparison [[#5547](https://github.com/plotly/plotly.py/pull/5547)], with thanks to @RazerM for the contribution! diff --git a/plotly/io/_defaults.py b/plotly/io/_defaults.py index c36530c342..ba4e48b18e 100644 --- a/plotly/io/_defaults.py +++ b/plotly/io/_defaults.py @@ -14,6 +14,9 @@ def __init__(self): self.mathjax = None self.topojson = None self.plotlyjs = None + # This header is necessary to comply with Open Street Map tile policy: + # https://openstreetmap.github.io/owg-website/policies/tiles/#31-identification + self.headers = {"X-Requested-With": "plotly.py"} defaults = _Defaults() diff --git a/plotly/io/_kaleido.py b/plotly/io/_kaleido.py index d0bb0eec43..09a6edafdf 100644 --- a/plotly/io/_kaleido.py +++ b/plotly/io/_kaleido.py @@ -375,6 +375,8 @@ def to_image( kopts["plotlyjs"] = defaults.plotlyjs if defaults.mathjax: kopts["mathjax"] = defaults.mathjax + if defaults.headers: + kopts["headers"] = defaults.headers width = ( width @@ -712,6 +714,8 @@ def write_images( kopts["plotlyjs"] = defaults.plotlyjs if defaults.mathjax: kopts["mathjax"] = defaults.mathjax + if defaults.headers: + kopts["headers"] = defaults.headers kaleido.write_fig_from_object_sync( kaleido_specs, kopts=kopts,