Skip to content

Commit 1490ace

Browse files
webgl trendlines
1 parent bb52dbc commit 1490ace

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

Diff for: CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
66

77
### Added
88

9-
- `px.NO_COLOR` constant to override wide-form color assignment
9+
- `px.NO_COLOR` constant to override wide-form color assignment in Plotly Express
10+
- trendline traces are now of type `scattergl` when `render_mode="webgl"` in Plotly Express
1011

1112

1213
## [4.8.2] - 2020-06-26

Diff for: packages/python/plotly/plotly/express/_core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ def make_trace_spec(args, constructor, attrs, trace_patch):
843843
# Add trendline trace specifications
844844
if "trendline" in args and args["trendline"]:
845845
trace_spec = TraceSpec(
846-
constructor=go.Scatter,
846+
constructor=go.Scattergl if constructor == go.Scattergl else go.Scatter,
847847
attrs=["trendline"],
848848
trace_patch=dict(mode="lines"),
849849
marginal=None,

Diff for: packages/python/plotly/plotly/tests/test_core/test_px/test_px.py

+22
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,25 @@ def test_marginal_ranges():
253253
)
254254
assert fig.layout.xaxis2.range is None
255255
assert fig.layout.yaxis3.range is None
256+
257+
258+
def test_render_mode():
259+
df = px.data.gapminder()
260+
df2007 = df.query("year == 2007")
261+
fig = px.scatter(df2007, x="gdpPercap", y="lifeExp", trendline="ols")
262+
assert fig.data[0].type == "scatter"
263+
assert fig.data[1].type == "scatter"
264+
fig = px.scatter(
265+
df2007, x="gdpPercap", y="lifeExp", trendline="ols", render_mode="webgl"
266+
)
267+
assert fig.data[0].type == "scattergl"
268+
assert fig.data[1].type == "scattergl"
269+
fig = px.scatter(df, x="gdpPercap", y="lifeExp", trendline="ols")
270+
assert fig.data[0].type == "scattergl"
271+
assert fig.data[1].type == "scattergl"
272+
fig = px.scatter(df, x="gdpPercap", y="lifeExp", trendline="ols", render_mode="svg")
273+
assert fig.data[0].type == "scatter"
274+
assert fig.data[1].type == "scatter"
275+
fig = px.density_contour(df, x="gdpPercap", y="lifeExp", trendline="ols")
276+
assert fig.data[0].type == "histogram2dcontour"
277+
assert fig.data[1].type == "scatter"

0 commit comments

Comments
 (0)