Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 8cda34b

Browse files
ismailuddinnicolaskruchten
authored andcommitted
Marker Opacity (#22)
* Added support for opacity kwarg to scatter, scatter_3d, scatter_matrix and scatter_polar * Removed from `attrables` * Added None check * Adjust docstring
1 parent dcb91a3 commit 8cda34b

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

plotly_express/_chart_types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def scatter(
1818
x=None,
1919
y=None,
2020
color=None,
21+
opacity=None,
2122
symbol=None,
2223
size=None,
2324
hover_name=None,
@@ -325,6 +326,7 @@ def scatter_3d(
325326
y=None,
326327
z=None,
327328
color=None,
329+
opacity=None,
328330
symbol=None,
329331
size=None,
330332
text=None,
@@ -416,6 +418,7 @@ def scatter_ternary(
416418
b=None,
417419
c=None,
418420
color=None,
421+
opacity=None,
419422
symbol=None,
420423
size=None,
421424
text=None,
@@ -483,6 +486,7 @@ def scatter_polar(
483486
r=None,
484487
theta=None,
485488
color=None,
489+
opacity=None,
486490
symbol=None,
487491
size=None,
488492
hover_name=None,
@@ -774,6 +778,7 @@ def scatter_matrix(
774778
data_frame,
775779
dimensions=None,
776780
color=None,
781+
opacity=None,
777782
symbol=None,
778783
size=None,
779784
category_orders={},

plotly_express/_core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ def make_trace_kwargs(args, trace_spec, g, mapping_labels, sizeref, color_range)
141141
result["marker"]["sizemode"] = "area"
142142
result["marker"]["sizeref"] = sizeref
143143
mapping_labels.append(("%s=%%{%s}" % (v_label, "marker.size"), None))
144-
145144
elif k == "trendline":
146145
if v in ["ols", "lowess"] and args["x"] and args["y"] and len(g) > 1:
147146
import statsmodels.api as sm
@@ -620,6 +619,8 @@ def infer_config(args, constructor, trace_patch):
620619
grouped_attrs.append("marker.symbol")
621620

622621
trace_patch = trace_patch.copy()
622+
if "opacity" in args:
623+
trace_patch["marker"] = dict(opacity=args["opacity"])
623624
if "line_group" in args:
624625
trace_patch["mode"] = "lines" + ("+markers+text" if args["text"] else "")
625626
elif constructor != go.Splom and (

plotly_express/_doc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@
9191
"Ignored if `error_z` is `None`.",
9292
],
9393
color=[colref, "Values from this column are used to assign color to marks."],
94+
opacity=[
95+
"(number, between 0 and 1) Sets the opacity for markers."
96+
],
9497
line_dash=[
9598
colref,
9699
"Values from this column are used to assign dash-patterns to lines.",

0 commit comments

Comments
 (0)