Skip to content

Commit f0982f6

Browse files
back out KDE
1 parent 9fda5b0 commit f0982f6

File tree

5 files changed

+3
-81
lines changed

5 files changed

+3
-81
lines changed

packages/python/plotly/plotly/express/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
strip,
3636
histogram,
3737
ecdf,
38-
kde,
3938
scatter_matrix,
4039
parallel_coordinates,
4140
parallel_categories,
@@ -92,7 +91,6 @@
9291
"strip",
9392
"histogram",
9493
"ecdf",
95-
"kde",
9694
"choropleth",
9795
"choropleth_mapbox",
9896
"pie",

packages/python/plotly/plotly/express/_chart_types.py

-53
Original file line numberDiff line numberDiff line change
@@ -551,59 +551,6 @@ def ecdf(
551551
)
552552

553553

554-
def kde(
555-
data_frame=None,
556-
x=None,
557-
y=None,
558-
color=None,
559-
line_dash=None,
560-
facet_row=None,
561-
facet_col=None,
562-
facet_col_wrap=0,
563-
facet_row_spacing=None,
564-
facet_col_spacing=None,
565-
hover_name=None,
566-
hover_data=None,
567-
animation_frame=None,
568-
animation_group=None,
569-
category_orders=None,
570-
labels=None,
571-
color_discrete_sequence=None,
572-
color_discrete_map=None,
573-
line_dash_sequence=None,
574-
line_dash_map=None,
575-
marginal=None,
576-
opacity=None,
577-
orientation=None,
578-
bw_method=None,
579-
render_mode="auto",
580-
log_x=False,
581-
log_y=False,
582-
range_x=None,
583-
range_y=None,
584-
title=None,
585-
template=None,
586-
width=None,
587-
height=None,
588-
):
589-
"""
590-
In a Kernel Density Estimation (KDE) plot, rows of `data_frame` are used as inputs
591-
to a KDE smoothing function and a line is drawn with one point pre row of input.
592-
"""
593-
return make_figure(args=locals(), constructor=go.Scatter)
594-
595-
596-
kde.__doc__ = make_docstring(
597-
kde,
598-
append_dict=dict(
599-
x=["If `orientation` is `'h'`, this argument is used as KDE weights."]
600-
+ _wide_mode_xy_append,
601-
y=["If `orientation` is `'v'`, this argument is used as KDE weights."]
602-
+ _wide_mode_xy_append,
603-
),
604-
)
605-
606-
607554
def violin(
608555
data_frame=None,
609556
x=None,

packages/python/plotly/plotly/express/_core.py

+2-20
Original file line numberDiff line numberDiff line change
@@ -1322,9 +1322,7 @@ def build_dataframe(args, constructor):
13221322
wide_cross_name = None # will likely be "index" in wide_mode
13231323
value_name = None # will likely be "value" in wide_mode
13241324
hist2d_types = [go.Histogram2d, go.Histogram2dContour]
1325-
hist1d_orientation = (
1326-
constructor == go.Histogram or "ecdfmode" in args or "bw_method" in args
1327-
)
1325+
hist1d_orientation = constructor == go.Histogram or "ecdfmode" in args
13281326
if constructor in cartesians:
13291327
if wide_x and wide_y:
13301328
raise ValueError(
@@ -1811,7 +1809,7 @@ def infer_config(args, constructor, trace_patch, layout_patch):
18111809
trace_patch["marker"] = dict(opacity=args["opacity"])
18121810
if (
18131811
"line_group" in args or "line_dash" in args
1814-
): # px.line, px.line_*, px.area, px.ecdf, px, kde
1812+
): # px.line, px.line_*, px.area, px.ecdf
18151813
modes = set()
18161814
if args.get("lines", True):
18171815
modes.add("lines")
@@ -1872,9 +1870,6 @@ def infer_config(args, constructor, trace_patch, layout_patch):
18721870
)
18731871
args["histnorm"] = args["ecdfnorm"]
18741872

1875-
if "bw_method" in args:
1876-
args["histnorm"] = "density"
1877-
18781873
# Compute applicable grouping attributes
18791874
for k in group_attrables:
18801875
if k in args:
@@ -2107,19 +2102,6 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
21072102
elif args["ecdfnorm"] == "percent":
21082103
group[var] = 100.0 * group[var] / group_sum
21092104

2110-
if "bw_method" in args:
2111-
from scipy.stats import gaussian_kde
2112-
2113-
base = args["x"] if args["orientation"] == "v" else args["y"]
2114-
var = args["x"] if args["orientation"] == "h" else args["y"]
2115-
bw = args.get("bw_method")
2116-
group = group.sort_values(by=base)
2117-
2118-
kernel = gaussian_kde(
2119-
dataset=group[base], weights=group[var], bw_method=bw
2120-
)
2121-
group[var] = kernel.evaluate(group[base])
2122-
21232105
patch, fit_results = make_trace_kwargs(
21242106
args, trace_spec, group, mapping_labels.copy(), sizeref
21252107
)

packages/python/plotly/plotly/express/_doc.py

-5
Original file line numberDiff line numberDiff line change
@@ -577,11 +577,6 @@
577577
"If `'complementary'`, the CCDF is plotted such that values represent data above the point.",
578578
"If `'reversed'`, a variant of the CCDF is plotted such that values represent data at or above the point.",
579579
],
580-
bw_method=[
581-
"str, scalar or callable (default `'scott'`)",
582-
"If str, must be one of `'scott'` or `'silverman'`.",
583-
"Passed to `scipy.stats.gaussian_kde`.",
584-
],
585580
)
586581

587582

packages/python/plotly/plotly/tests/test_optional/test_px/test_marginals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_xy_marginals(px_fn, marginal_x, marginal_y):
1414
assert len(fig.data) == 1 + (marginal_x is not None) + (marginal_y is not None)
1515

1616

17-
@pytest.mark.parametrize("px_fn", [px.histogram, px.ecdf, px.kde])
17+
@pytest.mark.parametrize("px_fn", [px.histogram, px.ecdf])
1818
@pytest.mark.parametrize("marginal", [None, "rug", "histogram", "box", "violin"])
1919
@pytest.mark.parametrize("orientation", ["h", "v"])
2020
def test_single_marginals(px_fn, marginal, orientation):

0 commit comments

Comments
 (0)