marginal-distribution subplots include overall-trendline #4669
Copy link
Copy link
Open
Labels
Description
When creating a scatter plot with marginal distributions and an overall trendline (but not trace trendline), the trendline is shown on all three subplots instead of only the main one.
See related StackOverflow question with suggested workarounds.
Repro code:
import numpy as np
import pandas as pd
import plotly.io as pio
import plotly.express as px
pio.renderers.default = "browser"
np.random.seed(42)
data = pd.DataFrame(np.random.randint(0, 100, (100, 4)), columns=["feature1", "feature2", "feature3", "feature4"])
data["label"] = np.random.choice(list("ABC"), 100)
data["is_outlier"] = np.random.choice([True, False], 100)
fig = px.scatter(
data, x="feature1", y="feature2",
color="label", symbol="is_outlier", symbol_map={True: "x", False: "circle"},
log_x=False, marginal_x="box",
log_y=False, marginal_y="box",
trendline="ols", trendline_scope="overall", trendline_color_override='black',
trendline_options=dict(log_x=False, log_y=False),
)
fig.show()
Reactions are currently unavailable

Activity
Keep overall trendline off marginal subplots