簡體   English   中英

如何從 Plotly Python 的 Box 中取出一些東西?

[英]How to remove something from the Box in Plotly Python?

這段代碼的哪一行:

# 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")

關於下圖中標記的片段,我想從圖表中刪除這些片段以及我必須刪除哪些代碼行才能實現這個目標。 我將非常感謝所有明確的答案,因為我找不到刪除 plot 的這個片段的代碼行。非常感謝!

在此處輸入圖像描述

如果你想完全刪除點,你應該刪除每個 go.Box 中的參數:

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

來自plot.ly/python/box-plots/ :使用points參數,顯示所有點 ( all )、僅離群值 ( outliers , default ) 或都不顯示 ( False ) 的基礎數據點。

Plot 1: boxpoints = False

在此處輸入圖像描述

Plot 2: boxpoints = 'all'

在此處輸入圖像描述

我遇到了同樣的問題,但仍然找不到解決方法。 Ahmed 提到的 github 問題仍然懸而未決 ( https://github.com/plotly/plotly.js/issues/277 )。

雖然,您可以使用可見的解決方法。 它不能解決問題。 但對於願景來說,它是固定的。 你 van marker=dict(opacity=0)這使得點不可見。 當你 hover 超過他們時,他們還在那里。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM