Skip to content

Commit 08a39fa

Browse files
authored
Merge pull request #4390 from plotly/update-plotly-js-2.27.0
Update plotly.js version to 2.27.0 and add example
2 parents 57e4d1d + ab946dd commit 08a39fa

File tree

16 files changed

+225
-11
lines changed

16 files changed

+225
-11
lines changed

Diff for: CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## [UNRELEASED]
66

7+
### Updated
8+
- Updated Plotly.js from version 2.26.0 to version 2.27.0. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#2270----2023-10-20) for more information. These changes are reflected in the auto-generated `plotly.graph_objects` module. Notable changes include:
9+
- Add `insiderange` to cartesian axes to help avoid overlap between visible grid lines and tick labels of the counter axis when they are positioned inside [[#6735](https://github.com/plotly/plotly.js/pull/6735)], this feature was anonymously sponsored: thank you to our sponsor!
10+
- Fix column order changes on hover [[#6718](https://github.com/plotly/plotly.js/pull/6718)],
11+
with thanks to @bhavinpatel1109 for the contribution!
12+
- Fix hover at timestamp '1970-01-01 00:00:00' [[#6752](https://github.com/plotly/plotly.js/pull/6752)],
13+
with thanks to @adamjhawley for the contribution!
14+
- Fix clearing empty `candlestick` using react [[#6757](https://github.com/plotly/plotly.js/pull/6757)]
15+
716
### Fixed
817
- Repair crash on Matplotlib 3.8 related to get_offset_position [[#4372](https://github.com/plotly/plotly.py/pull/4372)],
918
- Handle deprecation of `pandas.Series.dt.to_pydatetime()` calls and suppress the `FutureWarning` they currently emit. [[#4379](https://github.com/plotly/plotly.py/pull/4379)]

Diff for: doc/python/axes.md

+19
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,25 @@ fig.update_yaxes(range=[3, 9])
559559
fig.show()
560560
```
561561

562+
#### Exclude Inside Tick Labels from Range
563+
564+
*New in 5.18*
565+
566+
You can use `insiderange` instead of `range` on an axis if you have tick labels positioned on the inside of another axis and you don't want the range to overlap with those labels.
567+
568+
In this example, we have a y axis with `ticklabelposition="inside"` and by setting `insiderange=['2018-10-01', '2019-01-01']` on the x axis, the data point of `2018-10-01` is displayed after the y axis labels.
569+
570+
```python
571+
import plotly.express as px
572+
df = px.data.stocks(indexed=True)
573+
574+
fig = px.line(df, df.index, y="GOOG")
575+
fig.update_yaxes(ticklabelposition="inside", title="Price")
576+
fig.update_xaxes(insiderange=['2018-10-01', '2019-01-01'], title="Date")
577+
578+
fig.show()
579+
```
580+
562581
#### Setting only a Lower or Upper Bound for Range
563582

564583
*New in 5.17*

Diff for: packages/javascript/jupyterlab-plotly/package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/javascript/jupyterlab-plotly/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"@lumino/messaging": "^1.2.3",
6666
"@lumino/widgets": "^1.8.1",
6767
"lodash": "^4.17.4",
68-
"plotly.js": "^2.26.0"
68+
"plotly.js": "^2.27.0"
6969
},
7070
"jupyterlab": {
7171
"extension": "lib/jupyterlab-plugin",

Diff for: packages/python/plotly/codegen/resources/plot-schema.json

+30
Original file line numberDiff line numberDiff line change
@@ -10892,6 +10892,21 @@
1089210892
"editType": "none",
1089310893
"valType": "string"
1089410894
},
10895+
"insiderange": {
10896+
"description": "Could be used to set the desired inside range of this axis (excluding the labels) when `ticklabelposition` of the anchored axis has *inside*. Not implemented for axes with `type` *log*. This would be ignored when `range` is provided.",
10897+
"editType": "plot",
10898+
"items": [
10899+
{
10900+
"editType": "plot",
10901+
"valType": "any"
10902+
},
10903+
{
10904+
"editType": "plot",
10905+
"valType": "any"
10906+
}
10907+
],
10908+
"valType": "info_array"
10909+
},
1089510910
"labelalias": {
1089610911
"description": "Replacement text for specific tick or hover labels. For example using {US: 'USA', CA: 'Canada'} changes US to USA and CA to Canada. The labels we would have shown must match the keys exactly, after adding any tickprefix or ticksuffix. For negative numbers the minus sign symbol used (U+2212) is wider than the regular ascii dash. That means you need to use −1 instead of -1. labelalias can be used with any axis type, and both keys (if needed) and values (if desired) can include html-like tags or MathJax.",
1089710912
"dflt": false,
@@ -12217,6 +12232,21 @@
1221712232
"editType": "none",
1221812233
"valType": "string"
1221912234
},
12235+
"insiderange": {
12236+
"description": "Could be used to set the desired inside range of this axis (excluding the labels) when `ticklabelposition` of the anchored axis has *inside*. Not implemented for axes with `type` *log*. This would be ignored when `range` is provided.",
12237+
"editType": "plot",
12238+
"items": [
12239+
{
12240+
"editType": "plot",
12241+
"valType": "any"
12242+
},
12243+
{
12244+
"editType": "plot",
12245+
"valType": "any"
12246+
}
12247+
],
12248+
"valType": "info_array"
12249+
},
1222012250
"labelalias": {
1222112251
"description": "Replacement text for specific tick or hover labels. For example using {US: 'USA', CA: 'Canada'} changes US to USA and CA to Canada. The labels we would have shown must match the keys exactly, after adding any tickprefix or ticksuffix. For negative numbers the minus sign symbol used (U+2212) is wider than the regular ascii dash. That means you need to use −1 instead of -1. labelalias can be used with any axis type, and both keys (if needed) and values (if desired) can include html-like tags or MathJax.",
1222212252
"dflt": false,

Diff for: packages/python/plotly/plotly/graph_objs/_layout.py

+14
Original file line numberDiff line numberDiff line change
@@ -4424,6 +4424,13 @@ def xaxis(self):
44244424
example, *2016-10-13 09:15:23.456* with
44254425
tickformat "%H~%M~%S.%2f" would display
44264426
"09~15~23.46"
4427+
insiderange
4428+
Could be used to set the desired inside range
4429+
of this axis (excluding the labels) when
4430+
`ticklabelposition` of the anchored axis has
4431+
"inside". Not implemented for axes with `type`
4432+
"log". This would be ignored when `range` is
4433+
provided.
44274434
labelalias
44284435
Replacement text for specific tick or hover
44294436
labels. For example using {US: 'USA', CA:
@@ -4986,6 +4993,13 @@ def yaxis(self):
49864993
example, *2016-10-13 09:15:23.456* with
49874994
tickformat "%H~%M~%S.%2f" would display
49884995
"09~15~23.46"
4996+
insiderange
4997+
Could be used to set the desired inside range
4998+
of this axis (excluding the labels) when
4999+
`ticklabelposition` of the anchored axis has
5000+
"inside". Not implemented for axes with `type`
5001+
"log". This would be ignored when `range` is
5002+
provided.
49895003
labelalias
49905004
Replacement text for specific tick or hover
49915005
labels. For example using {US: 'USA', CA:

Diff for: packages/python/plotly/plotly/graph_objs/layout/_xaxis.py

+44
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class XAxis(_BaseLayoutHierarchyType):
3131
"griddash",
3232
"gridwidth",
3333
"hoverformat",
34+
"insiderange",
3435
"labelalias",
3536
"layer",
3637
"linecolor",
@@ -793,6 +794,32 @@ def hoverformat(self):
793794
def hoverformat(self, val):
794795
self["hoverformat"] = val
795796

797+
# insiderange
798+
# -----------
799+
@property
800+
def insiderange(self):
801+
"""
802+
Could be used to set the desired inside range of this axis
803+
(excluding the labels) when `ticklabelposition` of the anchored
804+
axis has "inside". Not implemented for axes with `type` "log".
805+
This would be ignored when `range` is provided.
806+
807+
The 'insiderange' property is an info array that may be specified as:
808+
809+
* a list or tuple of 2 elements where:
810+
(0) The 'insiderange[0]' property accepts values of any type
811+
(1) The 'insiderange[1]' property accepts values of any type
812+
813+
Returns
814+
-------
815+
list
816+
"""
817+
return self["insiderange"]
818+
819+
@insiderange.setter
820+
def insiderange(self, val):
821+
self["insiderange"] = val
822+
796823
# labelalias
797824
# ----------
798825
@property
@@ -2974,6 +3001,12 @@ def _prop_descriptions(self):
29743001
seconds with n digits. For example, *2016-10-13
29753002
09:15:23.456* with tickformat "%H~%M~%S.%2f" would
29763003
display "09~15~23.46"
3004+
insiderange
3005+
Could be used to set the desired inside range of this
3006+
axis (excluding the labels) when `ticklabelposition` of
3007+
the anchored axis has "inside". Not implemented for
3008+
axes with `type` "log". This would be ignored when
3009+
`range` is provided.
29773010
labelalias
29783011
Replacement text for specific tick or hover labels. For
29793012
example using {US: 'USA', CA: 'Canada'} changes US to
@@ -3336,6 +3369,7 @@ def __init__(
33363369
griddash=None,
33373370
gridwidth=None,
33383371
hoverformat=None,
3372+
insiderange=None,
33393373
labelalias=None,
33403374
layer=None,
33413375
linecolor=None,
@@ -3551,6 +3585,12 @@ def __init__(
35513585
seconds with n digits. For example, *2016-10-13
35523586
09:15:23.456* with tickformat "%H~%M~%S.%2f" would
35533587
display "09~15~23.46"
3588+
insiderange
3589+
Could be used to set the desired inside range of this
3590+
axis (excluding the labels) when `ticklabelposition` of
3591+
the anchored axis has "inside". Not implemented for
3592+
axes with `type` "log". This would be ignored when
3593+
`range` is provided.
35543594
labelalias
35553595
Replacement text for specific tick or hover labels. For
35563596
example using {US: 'USA', CA: 'Canada'} changes US to
@@ -4006,6 +4046,10 @@ def __init__(
40064046
_v = hoverformat if hoverformat is not None else _v
40074047
if _v is not None:
40084048
self["hoverformat"] = _v
4049+
_v = arg.pop("insiderange", None)
4050+
_v = insiderange if insiderange is not None else _v
4051+
if _v is not None:
4052+
self["insiderange"] = _v
40094053
_v = arg.pop("labelalias", None)
40104054
_v = labelalias if labelalias is not None else _v
40114055
if _v is not None:

Diff for: packages/python/plotly/plotly/graph_objs/layout/_yaxis.py

+44
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class YAxis(_BaseLayoutHierarchyType):
3232
"griddash",
3333
"gridwidth",
3434
"hoverformat",
35+
"insiderange",
3536
"labelalias",
3637
"layer",
3738
"linecolor",
@@ -817,6 +818,32 @@ def hoverformat(self):
817818
def hoverformat(self, val):
818819
self["hoverformat"] = val
819820

821+
# insiderange
822+
# -----------
823+
@property
824+
def insiderange(self):
825+
"""
826+
Could be used to set the desired inside range of this axis
827+
(excluding the labels) when `ticklabelposition` of the anchored
828+
axis has "inside". Not implemented for axes with `type` "log".
829+
This would be ignored when `range` is provided.
830+
831+
The 'insiderange' property is an info array that may be specified as:
832+
833+
* a list or tuple of 2 elements where:
834+
(0) The 'insiderange[0]' property accepts values of any type
835+
(1) The 'insiderange[1]' property accepts values of any type
836+
837+
Returns
838+
-------
839+
list
840+
"""
841+
return self["insiderange"]
842+
843+
@insiderange.setter
844+
def insiderange(self, val):
845+
self["insiderange"] = val
846+
820847
# labelalias
821848
# ----------
822849
@property
@@ -2904,6 +2931,12 @@ def _prop_descriptions(self):
29042931
seconds with n digits. For example, *2016-10-13
29052932
09:15:23.456* with tickformat "%H~%M~%S.%2f" would
29062933
display "09~15~23.46"
2934+
insiderange
2935+
Could be used to set the desired inside range of this
2936+
axis (excluding the labels) when `ticklabelposition` of
2937+
the anchored axis has "inside". Not implemented for
2938+
axes with `type` "log". This would be ignored when
2939+
`range` is provided.
29072940
labelalias
29082941
Replacement text for specific tick or hover labels. For
29092942
example using {US: 'USA', CA: 'Canada'} changes US to
@@ -3270,6 +3303,7 @@ def __init__(
32703303
griddash=None,
32713304
gridwidth=None,
32723305
hoverformat=None,
3306+
insiderange=None,
32733307
labelalias=None,
32743308
layer=None,
32753309
linecolor=None,
@@ -3491,6 +3525,12 @@ def __init__(
34913525
seconds with n digits. For example, *2016-10-13
34923526
09:15:23.456* with tickformat "%H~%M~%S.%2f" would
34933527
display "09~15~23.46"
3528+
insiderange
3529+
Could be used to set the desired inside range of this
3530+
axis (excluding the labels) when `ticklabelposition` of
3531+
the anchored axis has "inside". Not implemented for
3532+
axes with `type` "log". This would be ignored when
3533+
`range` is provided.
34943534
labelalias
34953535
Replacement text for specific tick or hover labels. For
34963536
example using {US: 'USA', CA: 'Canada'} changes US to
@@ -3953,6 +3993,10 @@ def __init__(
39533993
_v = hoverformat if hoverformat is not None else _v
39543994
if _v is not None:
39553995
self["hoverformat"] = _v
3996+
_v = arg.pop("insiderange", None)
3997+
_v = insiderange if insiderange is not None else _v
3998+
if _v is not None:
3999+
self["insiderange"] = _v
39564000
_v = arg.pop("labelalias", None)
39574001
_v = labelalias if labelalias is not None else _v
39584002
if _v is not None:
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# DO NOT EDIT
22
# This file is generated by the updatebundle setup.py command
3-
__plotlyjs_version__ = "2.26.0"
3+
__plotlyjs_version__ = "2.27.0"

Diff for: packages/python/plotly/plotly/package_data/plotly.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/python/plotly/plotly/validators/layout/_xaxis.py

+7
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ def __init__(self, plotly_name="xaxis", parent_name="layout", **kwargs):
169169
example, *2016-10-13 09:15:23.456* with
170170
tickformat "%H~%M~%S.%2f" would display
171171
"09~15~23.46"
172+
insiderange
173+
Could be used to set the desired inside range
174+
of this axis (excluding the labels) when
175+
`ticklabelposition` of the anchored axis has
176+
"inside". Not implemented for axes with `type`
177+
"log". This would be ignored when `range` is
178+
provided.
172179
labelalias
173180
Replacement text for specific tick or hover
174181
labels. For example using {US: 'USA', CA:

Diff for: packages/python/plotly/plotly/validators/layout/_yaxis.py

+7
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ def __init__(self, plotly_name="yaxis", parent_name="layout", **kwargs):
177177
example, *2016-10-13 09:15:23.456* with
178178
tickformat "%H~%M~%S.%2f" would display
179179
"09~15~23.46"
180+
insiderange
181+
Could be used to set the desired inside range
182+
of this axis (excluding the labels) when
183+
`ticklabelposition` of the anchored axis has
184+
"inside". Not implemented for axes with `type`
185+
"log". This would be ignored when `range` is
186+
provided.
180187
labelalias
181188
Replacement text for specific tick or hover
182189
labels. For example using {US: 'USA', CA:

Diff for: packages/python/plotly/plotly/validators/layout/xaxis/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
from ._linecolor import LinecolorValidator
6868
from ._layer import LayerValidator
6969
from ._labelalias import LabelaliasValidator
70+
from ._insiderange import InsiderangeValidator
7071
from ._hoverformat import HoverformatValidator
7172
from ._gridwidth import GridwidthValidator
7273
from ._griddash import GriddashValidator
@@ -161,6 +162,7 @@
161162
"._linecolor.LinecolorValidator",
162163
"._layer.LayerValidator",
163164
"._labelalias.LabelaliasValidator",
165+
"._insiderange.InsiderangeValidator",
164166
"._hoverformat.HoverformatValidator",
165167
"._gridwidth.GridwidthValidator",
166168
"._griddash.GriddashValidator",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import _plotly_utils.basevalidators
2+
3+
4+
class InsiderangeValidator(_plotly_utils.basevalidators.InfoArrayValidator):
5+
def __init__(self, plotly_name="insiderange", parent_name="layout.xaxis", **kwargs):
6+
super(InsiderangeValidator, self).__init__(
7+
plotly_name=plotly_name,
8+
parent_name=parent_name,
9+
edit_type=kwargs.pop("edit_type", "plot"),
10+
items=kwargs.pop(
11+
"items",
12+
[
13+
{"editType": "plot", "valType": "any"},
14+
{"editType": "plot", "valType": "any"},
15+
],
16+
),
17+
**kwargs,
18+
)

0 commit comments

Comments
 (0)