Skip to content

Commit f2a593b

Browse files
committed
Merge upstream main and resolve changelog conflict
2 parents 12bf5ca + 3c1aeba commit f2a593b

8 files changed

Lines changed: 54 additions & 9 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Fixed
1111
- Fix single-color requests in `n_colors` and `sample_colorscale` raising `ZeroDivisionError` [[#5805](https://github.com/plotly/plotly.py/issues/5805)].
12+
- Fix figures in JupyterLab not redrawing when their output is updated with `update_display_data` (for example `DisplayHandle.update`), which also kept animations in other kernels on their first frame [[#5865](https://github.com/plotly/plotly.py/pull/5865)], with thanks to @AllenDowney for the contribution!
1213
- Fix `mpl_to_plotly` tick marker mirroring, axis positioning, and trace visibility for twinned and overlaid subplots (such as `twinx` and `twiny`) [[#5310](https://github.com/plotly/plotly.py/pull/5310)], with thanks to @robertoffmoura for the contribution!
1314
- Fix `mpl_to_plotly` losing matplotlib axis line colors by exporting the color of each axis's displayed spine to the plotly x and y axis `linecolor` [[#5311](https://github.com/plotly/plotly.py/pull/5311)], with thanks to @robertoffmoura for the contribution!
1415
- Fix concurrent first access to lazily initialized graph object properties, which could raise `ValueError("Invalid value")` [[#5691](https://github.com/plotly/plotly.py/pull/5691)], with thanks to @hb1915 for the contribution!
@@ -22,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2223
- Fix `convert_dash` mapping dotted lines (`linestyle=':'`) to invalid `'circle'` in Plotly, correctly converting them to `'dot'` and preserving custom dash patterns as pixel lists, [[#5719](https://github.com/plotly/plotly.py/pull/5719)] with thanks to @robertoffmoura for the contribution!
2324
- Fix Plotly Express mutating lists passed to the `x` or `y` arguments in wide mode [[#5727](https://github.com/plotly/plotly.py/pull/5727)], with thanks to @cpruijsen for the contribution!
2425
- Fix `px.sunburst`, `px.treemap` and `px.icicle` listing sectors in a different order on every run when `path` is used with a Polars DataFrame; sectors now follow their order of first appearance for all dataframe backends [[#5766](https://github.com/plotly/plotly.py/pull/5766)], with thanks to @Irahan2 for the contribution!
26+
- Fix `trendline_scope="overall"` drawing the overall trendline on the `marginal_x`/`marginal_y` subplots as well as the main plot; it is now drawn only on the main subplots [[#5780](https://github.com/plotly/plotly.py/pull/5780)], with thanks to @jayzhou2309 for the contribution!
2527
- Fix `mpl_to_plotly` conversion of matplotlib contour lines and line collections: close contour rings ending with `Z` codes, support dash styles, convert date x-axes, separate disjoint subpaths with `None` separators, hide line collection traces from the legend by default, and group consecutive same-style lines into single traces [[#5770](https://github.com/plotly/plotly.py/pull/5770)], with thanks to @robertoffmoura for the contribution!
2628
- Fix `plotly.io.write_images` ignoring `layout.width`/`layout.height` (and the template's) and exporting every figure at the default 700x500 size; it now uses the same width/height priority as `write_image` and `to_image` [[#5784](https://github.com/plotly/plotly.py/pull/5784)], with thanks to @breken-ai for the contribution!
2729
- Fix color utilities mutating the list of colors passed to them [[#5836](https://github.com/plotly/plotly.py/pull/5836)], with thanks to @Enesuygurs for the contribution!

‎js/lib/mimeExtension.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎js/src/mimeExtension.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,16 @@ export class RenderedPlotly extends Widget implements IRenderMime.IRenderer {
5454
*/
5555
renderModel(model: IRenderMime.IMimeModel): Promise<void> {
5656
if (this.hasGraphElement()) {
57-
// We already have a graph, don't overwrite it
58-
return Promise.resolve();
57+
// We already have a graph. Redraw it only if the figure has changed,
58+
// as it does when a kernel sends update_display_data. (createGraph
59+
// stores a PNG of the figure in the model, which calls renderModel
60+
// again with the same figure.)
61+
const previous = this._model?.data[this._mimeType];
62+
if (JSON.stringify(previous) === JSON.stringify(model.data[this._mimeType])) {
63+
return Promise.resolve();
64+
}
65+
this._model = model;
66+
return this.createGraph(model);
5967
}
6068

6169
// Save off reference to model so that we can regenerate the plot later

‎plotly/express/_core.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,9 +2834,13 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
28342834
args, trendline_spec, args["data_frame"], {}, sizeref
28352835
)
28362836
trendline_trace.update(patch)
2837-
fig.add_trace(
2838-
trendline_trace, row="all", col="all", exclude_empty_subplots=True
2839-
)
2837+
main_rows = nrows - 1 if args.get("marginal_x") is not None else nrows
2838+
main_cols = ncols - 1 if args.get("marginal_y") is not None else ncols
2839+
for row in range(1, main_rows + 1):
2840+
for col in range(1, main_cols + 1):
2841+
fig.add_trace(
2842+
trendline_trace, row=row, col=col, exclude_empty_subplots=True
2843+
)
28402844
fig.update_traces(selector=-1, showlegend=True)
28412845
if fit_results is not None:
28422846
trendline_rows.append(dict(px_fit_results=fit_results))

‎plotly/labextension/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"outputDir": "../plotly/labextension",
3434
"webpackConfig": "./webpack.config.js",
3535
"_build": {
36-
"load": "static/remoteEntry.1dda3c8f6e5cd2a3.js",
36+
"load": "static/remoteEntry.954b872b457cd897.js",
3737
"mimeExtension": "./mimeExtension"
3838
}
3939
}

plotly/labextension/static/0.03957c7088ad5ed0.js renamed to plotly/labextension/static/0.d6f08baae2d5090c.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plotly/labextension/static/remoteEntry.1dda3c8f6e5cd2a3.js renamed to plotly/labextension/static/remoteEntry.954b872b457cd897.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tests/test_optional/test_px/test_trendline.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,34 @@ def test_overall_trendline(backend):
264264
params3 = results3["px_fit_results"].iloc[0].params
265265

266266
assert np.all(np.array_equal(params1, params3))
267+
268+
269+
@pytest.mark.parametrize(
270+
"kwargs",
271+
[
272+
dict(marginal_x="box", marginal_y="box"),
273+
dict(marginal_x="histogram", facet_col="smoker"),
274+
dict(marginal_y="violin", facet_row="smoker"),
275+
],
276+
)
277+
def test_overall_trendline_skips_marginals(backend, kwargs):
278+
df = px.data.tips(return_type=backend)
279+
fig = px.scatter(
280+
df,
281+
x="total_bill",
282+
y="tip",
283+
color="sex",
284+
trendline="ols",
285+
trendline_scope="overall",
286+
**kwargs,
287+
)
288+
trendline_axes = [
289+
(t.xaxis, t.yaxis) for t in fig.data if t.name == "Overall Trendline"
290+
]
291+
scatter_axes = {
292+
(t.xaxis, t.yaxis)
293+
for t in fig.data
294+
if t.type == "scatter" and t.name != "Overall Trendline"
295+
}
296+
assert len(trendline_axes) == len(scatter_axes)
297+
assert set(trendline_axes) == scatter_axes

0 commit comments

Comments
 (0)