Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update plotly.js version to 2.27.0 and add example #4390

Merged
merged 5 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [UNRELEASED]

### Updated
- 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:
- 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!
- Fix column order changes on hover [[#6718](https://github.com/plotly/plotly.js/pull/6718)],
with thanks to @bhavinpatel1109 for the contribution!
- Fix hover at timestamp '1970-01-01 00:00:00' [[#6752](https://github.com/plotly/plotly.js/pull/6752)],
with thanks to @adamjhawley for the contribution!
- Fix clearing empty `candlestick` using react [[#6757](https://github.com/plotly/plotly.js/pull/6757)]

### Fixed
- Repair crash on Matplotlib 3.8 related to get_offset_position [[#4372](https://github.com/plotly/plotly.py/pull/4372)],
- 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)]
Expand Down
19 changes: 19 additions & 0 deletions doc/python/axes.md
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,25 @@ fig.update_yaxes(range=[3, 9])
fig.show()
```

#### Exclude Inside Tick Labels from Range

*New in 5.18*

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.

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.

```python
import plotly.express as px
df = px.data.stocks(indexed=True)

fig = px.line(df, df.index, y="GOOG")
fig.update_yaxes(ticklabelposition="inside", title="Price")
fig.update_xaxes(insiderange=['2018-10-01', '2019-01-01'], title="Date")

fig.show()
```

#### Setting only a Lower or Upper Bound for Range

*New in 5.17*
Expand Down
14 changes: 7 additions & 7 deletions packages/javascript/jupyterlab-plotly/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/javascript/jupyterlab-plotly/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@lumino/messaging": "^1.2.3",
"@lumino/widgets": "^1.8.1",
"lodash": "^4.17.4",
"plotly.js": "^2.26.0"
"plotly.js": "^2.27.0"
},
"jupyterlab": {
"extension": "lib/jupyterlab-plugin",
Expand Down
30 changes: 30 additions & 0 deletions packages/python/plotly/codegen/resources/plot-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10892,6 +10892,21 @@
"editType": "none",
"valType": "string"
},
"insiderange": {
"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.",
"editType": "plot",
"items": [
{
"editType": "plot",
"valType": "any"
},
{
"editType": "plot",
"valType": "any"
}
],
"valType": "info_array"
},
"labelalias": {
"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.",
"dflt": false,
Expand Down Expand Up @@ -12217,6 +12232,21 @@
"editType": "none",
"valType": "string"
},
"insiderange": {
"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.",
"editType": "plot",
"items": [
{
"editType": "plot",
"valType": "any"
},
{
"editType": "plot",
"valType": "any"
}
],
"valType": "info_array"
},
"labelalias": {
"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.",
"dflt": false,
Expand Down
14 changes: 14 additions & 0 deletions packages/python/plotly/plotly/graph_objs/_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -4424,6 +4424,13 @@ def xaxis(self):
example, *2016-10-13 09:15:23.456* with
tickformat "%H~%M~%S.%2f" would display
"09~15~23.46"
insiderange
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.
labelalias
Replacement text for specific tick or hover
labels. For example using {US: 'USA', CA:
Expand Down Expand Up @@ -4986,6 +4993,13 @@ def yaxis(self):
example, *2016-10-13 09:15:23.456* with
tickformat "%H~%M~%S.%2f" would display
"09~15~23.46"
insiderange
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.
labelalias
Replacement text for specific tick or hover
labels. For example using {US: 'USA', CA:
Expand Down
44 changes: 44 additions & 0 deletions packages/python/plotly/plotly/graph_objs/layout/_xaxis.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class XAxis(_BaseLayoutHierarchyType):
"griddash",
"gridwidth",
"hoverformat",
"insiderange",
"labelalias",
"layer",
"linecolor",
Expand Down Expand Up @@ -793,6 +794,32 @@ def hoverformat(self):
def hoverformat(self, val):
self["hoverformat"] = val

# insiderange
# -----------
@property
def insiderange(self):
"""
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.

The 'insiderange' property is an info array that may be specified as:

* a list or tuple of 2 elements where:
(0) The 'insiderange[0]' property accepts values of any type
(1) The 'insiderange[1]' property accepts values of any type

Returns
-------
list
"""
return self["insiderange"]

@insiderange.setter
def insiderange(self, val):
self["insiderange"] = val

# labelalias
# ----------
@property
Expand Down Expand Up @@ -2974,6 +3001,12 @@ def _prop_descriptions(self):
seconds with n digits. For example, *2016-10-13
09:15:23.456* with tickformat "%H~%M~%S.%2f" would
display "09~15~23.46"
insiderange
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.
labelalias
Replacement text for specific tick or hover labels. For
example using {US: 'USA', CA: 'Canada'} changes US to
Expand Down Expand Up @@ -3336,6 +3369,7 @@ def __init__(
griddash=None,
gridwidth=None,
hoverformat=None,
insiderange=None,
labelalias=None,
layer=None,
linecolor=None,
Expand Down Expand Up @@ -3551,6 +3585,12 @@ def __init__(
seconds with n digits. For example, *2016-10-13
09:15:23.456* with tickformat "%H~%M~%S.%2f" would
display "09~15~23.46"
insiderange
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.
labelalias
Replacement text for specific tick or hover labels. For
example using {US: 'USA', CA: 'Canada'} changes US to
Expand Down Expand Up @@ -4006,6 +4046,10 @@ def __init__(
_v = hoverformat if hoverformat is not None else _v
if _v is not None:
self["hoverformat"] = _v
_v = arg.pop("insiderange", None)
_v = insiderange if insiderange is not None else _v
if _v is not None:
self["insiderange"] = _v
_v = arg.pop("labelalias", None)
_v = labelalias if labelalias is not None else _v
if _v is not None:
Expand Down
44 changes: 44 additions & 0 deletions packages/python/plotly/plotly/graph_objs/layout/_yaxis.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class YAxis(_BaseLayoutHierarchyType):
"griddash",
"gridwidth",
"hoverformat",
"insiderange",
"labelalias",
"layer",
"linecolor",
Expand Down Expand Up @@ -817,6 +818,32 @@ def hoverformat(self):
def hoverformat(self, val):
self["hoverformat"] = val

# insiderange
# -----------
@property
def insiderange(self):
"""
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.

The 'insiderange' property is an info array that may be specified as:

* a list or tuple of 2 elements where:
(0) The 'insiderange[0]' property accepts values of any type
(1) The 'insiderange[1]' property accepts values of any type

Returns
-------
list
"""
return self["insiderange"]

@insiderange.setter
def insiderange(self, val):
self["insiderange"] = val

# labelalias
# ----------
@property
Expand Down Expand Up @@ -2904,6 +2931,12 @@ def _prop_descriptions(self):
seconds with n digits. For example, *2016-10-13
09:15:23.456* with tickformat "%H~%M~%S.%2f" would
display "09~15~23.46"
insiderange
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.
labelalias
Replacement text for specific tick or hover labels. For
example using {US: 'USA', CA: 'Canada'} changes US to
Expand Down Expand Up @@ -3270,6 +3303,7 @@ def __init__(
griddash=None,
gridwidth=None,
hoverformat=None,
insiderange=None,
labelalias=None,
layer=None,
linecolor=None,
Expand Down Expand Up @@ -3491,6 +3525,12 @@ def __init__(
seconds with n digits. For example, *2016-10-13
09:15:23.456* with tickformat "%H~%M~%S.%2f" would
display "09~15~23.46"
insiderange
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.
labelalias
Replacement text for specific tick or hover labels. For
example using {US: 'USA', CA: 'Canada'} changes US to
Expand Down Expand Up @@ -3953,6 +3993,10 @@ def __init__(
_v = hoverformat if hoverformat is not None else _v
if _v is not None:
self["hoverformat"] = _v
_v = arg.pop("insiderange", None)
_v = insiderange if insiderange is not None else _v
if _v is not None:
self["insiderange"] = _v
_v = arg.pop("labelalias", None)
_v = labelalias if labelalias is not None else _v
if _v is not None:
Expand Down
2 changes: 1 addition & 1 deletion packages/python/plotly/plotly/offline/_plotlyjs_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# DO NOT EDIT
# This file is generated by the updatebundle setup.py command
__plotlyjs_version__ = "2.26.0"
__plotlyjs_version__ = "2.27.0"
4 changes: 2 additions & 2 deletions packages/python/plotly/plotly/package_data/plotly.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions packages/python/plotly/plotly/validators/layout/_xaxis.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ def __init__(self, plotly_name="xaxis", parent_name="layout", **kwargs):
example, *2016-10-13 09:15:23.456* with
tickformat "%H~%M~%S.%2f" would display
"09~15~23.46"
insiderange
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.
labelalias
Replacement text for specific tick or hover
labels. For example using {US: 'USA', CA:
Expand Down
7 changes: 7 additions & 0 deletions packages/python/plotly/plotly/validators/layout/_yaxis.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ def __init__(self, plotly_name="yaxis", parent_name="layout", **kwargs):
example, *2016-10-13 09:15:23.456* with
tickformat "%H~%M~%S.%2f" would display
"09~15~23.46"
insiderange
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.
labelalias
Replacement text for specific tick or hover
labels. For example using {US: 'USA', CA:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
from ._linecolor import LinecolorValidator
from ._layer import LayerValidator
from ._labelalias import LabelaliasValidator
from ._insiderange import InsiderangeValidator
from ._hoverformat import HoverformatValidator
from ._gridwidth import GridwidthValidator
from ._griddash import GriddashValidator
Expand Down Expand Up @@ -161,6 +162,7 @@
"._linecolor.LinecolorValidator",
"._layer.LayerValidator",
"._labelalias.LabelaliasValidator",
"._insiderange.InsiderangeValidator",
"._hoverformat.HoverformatValidator",
"._gridwidth.GridwidthValidator",
"._griddash.GriddashValidator",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import _plotly_utils.basevalidators


class InsiderangeValidator(_plotly_utils.basevalidators.InfoArrayValidator):
def __init__(self, plotly_name="insiderange", parent_name="layout.xaxis", **kwargs):
super(InsiderangeValidator, self).__init__(
plotly_name=plotly_name,
parent_name=parent_name,
edit_type=kwargs.pop("edit_type", "plot"),
items=kwargs.pop(
"items",
[
{"editType": "plot", "valType": "any"},
{"editType": "plot", "valType": "any"},
],
),
**kwargs,
)
Loading