Skip to content

Commit 00c3238

Browse files
author
Joseph Damiba
committed
prevent creation of new px.default properties at run time
1 parent 9fb88c1 commit 00c3238

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

app.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import plotly.express as px
2+
px.defaults.template = "ggplot2"
3+
px.defaults.color_continuous_scale = px.colors.sequential.Blackbody
4+
px.defaults.width = 600
5+
px.defaults.height = 400
6+
px.defaults.blerd = "hlkjhlkjhjh"
7+
8+
df = px.data.iris()
9+
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="sepal_length", width=400)
10+
fig.show()

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717

1818
class PxDefaults(object):
19+
__slots__ = ['template', 'width', 'height', 'color_discrete_sequence', 'color_continuous_scale', 'symbol_sequence', 'line_dash_sequence', 'size_max']
20+
1921
def __init__(self):
2022
self.template = None
2123
self.width = None
@@ -25,8 +27,7 @@ def __init__(self):
2527
self.symbol_sequence = None
2628
self.line_dash_sequence = None
2729
self.size_max = 20
28-
29-
30+
3031
defaults = PxDefaults()
3132
del PxDefaults
3233

@@ -740,6 +741,7 @@ def one_group(x):
740741

741742
def apply_default_cascade(args):
742743
# first we apply px.defaults to unspecified args
744+
743745

744746
for param in (
745747
["color_discrete_sequence", "color_continuous_scale"]

0 commit comments

Comments
 (0)