Skip to content

Commit 33381b1

Browse files
back out KDE
1 parent 542ed5a commit 33381b1

File tree

5 files changed

+3
-81
lines changed

5 files changed

+3
-81
lines changed

Diff for: 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",

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

-53
Original file line numberDiff line numberDiff line change
@@ -555,59 +555,6 @@ def ecdf(
555555
)
556556

557557

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

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

+2-20
Original file line numberDiff line numberDiff line change
@@ -1318,9 +1318,7 @@ def build_dataframe(args, constructor):
13181318
wide_cross_name = None # will likely be "index" in wide_mode
13191319
value_name = None # will likely be "value" in wide_mode
13201320
hist2d_types = [go.Histogram2d, go.Histogram2dContour]
1321-
hist1d_orientation = (
1322-
constructor == go.Histogram or "ecdfmode" in args or "bw_method" in args
1323-
)
1321+
hist1d_orientation = constructor == go.Histogram or "ecdfmode" in args
13241322
if constructor in cartesians:
13251323
if wide_x and wide_y:
13261324
raise ValueError(
@@ -1807,7 +1805,7 @@ def infer_config(args, constructor, trace_patch, layout_patch):
18071805
trace_patch["marker"] = dict(opacity=args["opacity"])
18081806
if (
18091807
"line_group" in args or "line_dash" in args
1810-
): # px.line, px.line_*, px.area, px.ecdf, px, kde
1808+
): # px.line, px.line_*, px.area, px.ecdf
18111809
modes = set()
18121810
if args.get("lines", True):
18131811
modes.add("lines")
@@ -1878,9 +1876,6 @@ def infer_config(args, constructor, trace_patch, layout_patch):
18781876
)
18791877
args["histnorm"] = args["ecdfnorm"]
18801878

1881-
if "bw_method" in args:
1882-
args["histnorm"] = "density"
1883-
18841879
# Compute applicable grouping attributes
18851880
for k in group_attrables:
18861881
if k in args:
@@ -2113,19 +2108,6 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
21132108
elif args["ecdfnorm"] == "percent":
21142109
group[var] = 100.0 * group[var] / group_sum
21152110

2116-
if "bw_method" in args:
2117-
from scipy.stats import gaussian_kde
2118-
2119-
base = args["x"] if args["orientation"] == "v" else args["y"]
2120-
var = args["x"] if args["orientation"] == "h" else args["y"]
2121-
bw = args.get("bw_method")
2122-
group = group.sort_values(by=base)
2123-
2124-
kernel = gaussian_kde(
2125-
dataset=group[base], weights=group[var], bw_method=bw
2126-
)
2127-
group[var] = kernel.evaluate(group[base])
2128-
21292111
patch, fit_results = make_trace_kwargs(
21302112
args, trace_spec, group, mapping_labels.copy(), sizeref
21312113
)

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

-5
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,6 @@
591591
"If `'complementary'`, the CCDF is plotted such that values represent data above the point.",
592592
"If `'reversed'`, a variant of the CCDF is plotted such that values represent data at or above the point.",
593593
],
594-
bw_method=[
595-
"str, scalar or callable (default `'scott'`)",
596-
"If str, must be one of `'scott'` or `'silverman'`.",
597-
"Passed to `scipy.stats.gaussian_kde`.",
598-
],
599594
)
600595

601596

Diff for: 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)