Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Plotly box plot关闭异常值检测_Python_Plotly_Boxplot_Outliers - Fatal编程技术网

Python Plotly box plot关闭异常值检测

Python Plotly box plot关闭异常值检测,python,plotly,boxplot,outliers,Python,Plotly,Boxplot,Outliers,在Plotly(Python)中,默认情况下,方框图检测异常值,如果存在它决定为异常值的内容,则不会将胡须扩展到异常值。但是,我知道我的任何数据点都不应被视为异常值。是否可以在方框图中关闭异常值检测,并将整个数据集作为内联线处理 顺便说一下,我仍然想显示方框图旁边的所有点,因此,我不想使用选项boxpoints=False强制方框图包含所有点。目前唯一的方法似乎是使用多个跟踪,并将它们调整到与下面的绘图和代码片段相同的位置。如果您想了解一些细节,请查看最后的片段和绘图 在下面的代码片段中,我将使

在Plotly(Python)中,默认情况下,方框图检测异常值,如果存在它决定为异常值的内容,则不会将胡须扩展到异常值。但是,我知道我的任何数据点都不应被视为异常值。是否可以在方框图中关闭异常值检测,并将整个数据集作为内联线处理


顺便说一下,我仍然想显示方框图旁边的所有点,因此,我不想使用选项
boxpoints=False
强制方框图包含所有点。

目前唯一的方法似乎是使用多个跟踪,并将它们调整到与下面的绘图和代码片段相同的位置。如果您想了解一些细节,请查看最后的片段和绘图

在下面的代码片段中,我将使用
go.Box(x=x0)
处理两个不同的记录道,它们具有相同的数据,但标记和线的设置不同,以实现这一点:

绘图:

# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
x0 = y0
x0 = [0 for y in y0]

# include an outlier
y0[-1] = 4

# traces
trace0 = go.Box(x=x0,
                y=y0, boxpoints = False, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),
)

trace1 = go.Box(x=x0,
                y=y0, boxpoints = 'all', pointpos = 0,
                marker = dict(color = 'rgb(66, 66, 244)'),
                line = dict(color = 'rgba(0,0,0,0)'),
                fillcolor = 'rgba(0,0,0,0)'
)

data=[trace0, trace1]

# figure
fig = go.Figure(data)
fig.show()
# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
y0[-1] = 4

# traces
trace0 = go.Box(y=y0, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),

)

# figure
fig = go.Figure(trace0)
fig.show()
# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
y0[-1] = 4

# traces
trace0 = go.Box(y=y0, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),
                boxpoints = False
)

# figure
fig = go.Figure(trace0)
fig.show()

代码:

# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
x0 = y0
x0 = [0 for y in y0]

# include an outlier
y0[-1] = 4

# traces
trace0 = go.Box(x=x0,
                y=y0, boxpoints = False, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),
)

trace1 = go.Box(x=x0,
                y=y0, boxpoints = 'all', pointpos = 0,
                marker = dict(color = 'rgb(66, 66, 244)'),
                line = dict(color = 'rgba(0,0,0,0)'),
                fillcolor = 'rgba(0,0,0,0)'
)

data=[trace0, trace1]

# figure
fig = go.Figure(data)
fig.show()
# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
y0[-1] = 4

# traces
trace0 = go.Box(y=y0, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),

)

# figure
fig = go.Figure(trace0)
fig.show()
# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
y0[-1] = 4

# traces
trace0 = go.Box(y=y0, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),
                boxpoints = False
)

# figure
fig = go.Figure(trace0)
fig.show()

有关默认行为的详细信息:

# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
x0 = y0
x0 = [0 for y in y0]

# include an outlier
y0[-1] = 4

# traces
trace0 = go.Box(x=x0,
                y=y0, boxpoints = False, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),
)

trace1 = go.Box(x=x0,
                y=y0, boxpoints = 'all', pointpos = 0,
                marker = dict(color = 'rgb(66, 66, 244)'),
                line = dict(color = 'rgba(0,0,0,0)'),
                fillcolor = 'rgba(0,0,0,0)'
)

data=[trace0, trace1]

# figure
fig = go.Figure(data)
fig.show()
# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
y0[-1] = 4

# traces
trace0 = go.Box(y=y0, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),

)

# figure
fig = go.Figure(trace0)
fig.show()
# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
y0[-1] = 4

# traces
trace0 = go.Box(y=y0, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),
                boxpoints = False
)

# figure
fig = go.Figure(trace0)
fig.show()
如果未指定
Boxpoints
,则行将不包括异常值:

绘图:默认值

代码:

# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
x0 = y0
x0 = [0 for y in y0]

# include an outlier
y0[-1] = 4

# traces
trace0 = go.Box(x=x0,
                y=y0, boxpoints = False, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),
)

trace1 = go.Box(x=x0,
                y=y0, boxpoints = 'all', pointpos = 0,
                marker = dict(color = 'rgb(66, 66, 244)'),
                line = dict(color = 'rgba(0,0,0,0)'),
                fillcolor = 'rgba(0,0,0,0)'
)

data=[trace0, trace1]

# figure
fig = go.Figure(data)
fig.show()
# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
y0[-1] = 4

# traces
trace0 = go.Box(y=y0, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),

)

# figure
fig = go.Figure(trace0)
fig.show()
# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
y0[-1] = 4

# traces
trace0 = go.Box(y=y0, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),
                boxpoints = False
)

# figure
fig = go.Figure(trace0)
fig.show()
使包含异常值的行成为异常值的唯一方法是通过设置
boxpoints=False来删除所有的boxpoints

绘图:

# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
x0 = y0
x0 = [0 for y in y0]

# include an outlier
y0[-1] = 4

# traces
trace0 = go.Box(x=x0,
                y=y0, boxpoints = False, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),
)

trace1 = go.Box(x=x0,
                y=y0, boxpoints = 'all', pointpos = 0,
                marker = dict(color = 'rgb(66, 66, 244)'),
                line = dict(color = 'rgba(0,0,0,0)'),
                fillcolor = 'rgba(0,0,0,0)'
)

data=[trace0, trace1]

# figure
fig = go.Figure(data)
fig.show()
# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
y0[-1] = 4

# traces
trace0 = go.Box(y=y0, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),

)

# figure
fig = go.Figure(trace0)
fig.show()
# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
y0[-1] = 4

# traces
trace0 = go.Box(y=y0, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),
                boxpoints = False
)

# figure
fig = go.Figure(trace0)
fig.show()


代码:

# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
x0 = y0
x0 = [0 for y in y0]

# include an outlier
y0[-1] = 4

# traces
trace0 = go.Box(x=x0,
                y=y0, boxpoints = False, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),
)

trace1 = go.Box(x=x0,
                y=y0, boxpoints = 'all', pointpos = 0,
                marker = dict(color = 'rgb(66, 66, 244)'),
                line = dict(color = 'rgba(0,0,0,0)'),
                fillcolor = 'rgba(0,0,0,0)'
)

data=[trace0, trace1]

# figure
fig = go.Figure(data)
fig.show()
# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
y0[-1] = 4

# traces
trace0 = go.Box(y=y0, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),

)

# figure
fig = go.Figure(trace0)
fig.show()
# imports
import plotly
from plotly import tools
import pandas as pd
import numpy as np
import plotly.graph_objs as go

# setup
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
y0[-1] = 4

# traces
trace0 = go.Box(y=y0, pointpos = 0,
                marker = dict(color = 'rgb(66, 167, 244)'),
                boxpoints = False
)

# figure
fig = go.Figure(trace0)
fig.show()
当然,这不是你的目标

我希望这是有帮助的。如果没有,请毫不犹豫地告诉我