python - 如何在 Plotly Python 中从 Box 中删除某些内容?

标签 python pandas plotly seaborn

该代码的哪一行:

# Take credit amount values into a list
young = df['Credit_amount'].loc[df['Age_Group'] == 'Young'].values.tolist()
young_adults = df['Credit_amount'].loc[df['Age_Group'] == 'Young Adults'].values.tolist()
senior = df['Credit_amount'].loc[df['Age_Group'] == 'Senior'].values.tolist()
elder_credit = df['Credit_amount'].loc[df['Age_Group'] == 'Elder'].values.tolist()

# Create the box plots by age category
young_credit = go.Box(
    y = young,
    name = "Young",
    jitter = 0.3,
    pointpos = -1.8,
    boxpoints = 'all',
    marker = dict(
        color = 'rgb(150, 198, 109)'),
    line = dict(
        color = 'rgb(111, 200, 37)')
)

young_adults_credit = go.Box(
    y = young_adults,
    name = "Young Adults",
    jitter = 0.3,
    pointpos = -1.8,
    boxpoints = 'all',
    marker = dict(
        color = 'rgb(124, 236, 212)'),
    line = dict(
        color = 'rgb(38, 214, 177)')
)

senior_credit = go.Box(
    y = senior,
    name = "Seniors",
    jitter = 0.3,
    pointpos = -1.8,
    boxpoints = 'all',
    marker = dict(
        color = 'rgb(241, 93, 93)'),
    line = dict(
        color = 'rgb(225, 44, 44)')
)

elder_credit = go.Box(
    y = elder_credit,
    name = "Elders",
    jitter = 0.3,
    pointpos = -1.8,
    boxpoints = 'all',
    marker = dict(
        color = 'rgb(180, 121, 72)'),
    line = dict(
        color = 'rgb(115, 77, 46)')
)

data = [young_credit, young_adults_credit, senior_credit, elder_credit]

layout = dict(
    title="Credit Amount by Age Group Segment", 
    xaxis = dict(title="Age Group"),
    yaxis= dict(title="Credit Amount")
)

fig = dict(data=data, layout=layout)
iplot(fig, filename="Box Plot")

涉及下图中标记的片段,我想从图表中删除这些片段以及必须删除哪些代码行才能实现此目标。 我将非常感谢所有明确的答案,因为我找不到删除该 plotly 片段的代码行。 非常感谢!

enter image description here

最佳答案

如果你想完全删除点,你应该删除每个go.Box中的参数:

jitter = 0.3,
pointpos = -1.8,
boxpoints = 'all'

关于python - 如何在 Plotly Python 中从 Box 中删除某些内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60366174/

相关文章:

python - 凯拉斯 |类型错误 : __init__() missing 1 required positional argument: 'nb_col'

python - [IBM][CLI 驱动程序] SQL10013N 无法加载指定的库 "GSKit Error: 207"。 SQLSTATE=42724 SQLCODE=-10013

python - 查找条件中的第一个信号

python pandas 按组排序

plotly - 如何使用 px.box 在 Boxplot q1、q3、fences 中显示文本值(不是悬停)?

python - 如何解决错误 : TypeError: invalid Figure property: Layout Layout Bad property path: Layout ^^^^^^

python - Numpy,对每 N 个连续元素进行分组?

python - 值错误 : Cannot convert a Tensor of dtype resource to a NumPy array

python - 按每月营业日对 DataFrame 进行分组

python - 如何使用 slider 向 Plotly 条形图添加交互式文本?