- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下报道 here我尝试创建一个带有重叠散点图的箱线图。
但是当我运行时:
In [27]: table1.t_in[table1.duration==6]
Out[27]:
counter
7 308.351304
9 305.354920
14 307.832732
15 332.097405
21 309.711144
22 308.227617
23 317.342377
24 306.140126
25 339.185127
27 336.411869
30 313.287353
Name: t_in, dtype: float64
In [28]: table1.t_in[table1.duration==7]
Out[28]:
counter
10 401.891105
11 384.290236
13 387.516037
17 369.366080
18 383.584934
19 357.466159
20 380.888071
26 399.989748
34 353.118944
Name: t_in, dtype: float64
In [29]: fig,ax=plt.subplots()
...:
...: for i in [6,7]:
...: y = table1.t_in[table1.duration==i]
...: # Add some random "jitter" to the x-axis
...: x = np.random.normal(i, 0.03, size=len(y))
...: ax.plot(x, y, 'r.', alpha=0.5)
...:
...: bp = table1.boxplot(column='t_in',by='duration',grid=False,ax=ax)
我怎样才能像链接的问题一样绘图?
最佳答案
使用 ipython 笔记本。我尝试了matplotlib的boxplot-Methode。不能包含在 for 循环中。但希望它能有所帮助。
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
# data
table1 = pd.DataFrame({"t_in":[308.351304, 305.354920, 307.832732,
332.097405, 309.711144, 308.227617,
317.342377, 306.140126, 339.185127,
336.411869, 313.287353, 401.891105,
384.290236, 387.516037, 369.366080,
383.584934, 357.466159, 380.888071,
399.989748, 353.118944]},
index=[7,9,14,15,21,22,23,24,25,27,30,
10,11,13,17,18,19,20,26,34])
table1["duration"] = np.where(table1["t_in"]<353, 6, 7)
# plotting
fig,ax = plt.subplots()
colors = ["red", "blue"]
for i in [6,7]:
y = table1.t_in[table1.duration==i]
# Add some random "jitter" to the x-axis
x = np.random.normal(i, 0.03, size=len(y))
ax.scatter(x, y, c=colors[i-6], alpha=0.5)
ax.boxplot([table1.t_in[table1.duration==6].values,table1.t_in[table1.duration==7].values], positions=[6,7])
plt.show()
关于python - Pandas boxplot 覆盖/覆盖 matplotlib 图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32399657/
我想通过 Seaborn 中生成的箱线图获取特定值 (即,媒体,四分位数)。例如,在下面的箱线图中(来源:link) 有没有办法获得媒体和四分位数而不是手动估计? import numpy as np
我正在尝试创建箱线图,但遇到了这个错误 - “系列”对象没有属性“箱线图” 这是我当前的代码: fig = plt.figure(figsize=(8,6)) ax = fig.gca() frame
我无法在箱形图中使用名称。它不起作用是因为我只有一个向量吗?这是我尝试过的。 tmp = c(1,1,1,1,2,2,2,2,5,5,5,5,5,6,5,4,7) boxplot(tmp) boxpl
我正在使用 seaborn 创建箱线图。当我指定一列对框进行分组/着色时,框的宽度变得非常窄,以至于很难看到。我所做的唯一更改是为hue 指定一个参数,它指向传递的数据帧中的一列。我曾尝试使用 'wi
delme <- exp(rnorm(1000,1.5,0.3)) boxplot(delme,log="y") boxplot(log10(delme)) 为什么这两幅图中的 mustache 不同
我使用以下代码对以第 5 个和第 95 个百分位数作为上限和下限的值进行箱线图。令人惊讶的是,我通过在 python 2.7.3 中使用 matplotlib 1.4.0 和在 python 3.6.
我正在尝试将箱线图的异常值颜色与美学(scale_colour_discrete)设置的填充颜色相匹配。 这是一个例子。 m <- ggplot(movies, aes(y = votes, x =
我对 R 和 ggplot 还很陌生。 我正在尝试生成一个按两个变量排序的箱线图。就我而言,物种和实验。 到目前为止我得到了什么 ggplot(DF, aes(Species, Protein, fi
我有一个数据框,其中包含“季度”和“转售价格”列。我使用数据框使用seaborn绘制了箱线图。箱线图显示季度值,例如 (2007-Q2、2007-Q3、2007-Q4、2008-Q2)。但是,我希望它
我正在根据大数据(2150000 个案例)按年份绘制两组体重的简单箱线图。除去年的最后一组外,所有组的中位数都相同,但在箱线图上,它绘制得好像与其他组一样。 #boxplot ggplot(data
我正在将 datafame 的一些列绘制成箱线图。到目前为止,没问题。如下所示,我写了一些东西并且它有效。但是:第二个图也包含第一个图的图。正如你所看到的,我用“= None”或“del value”
下面的代码有助于获得具有独特颜色框的子图。但是所有子图共享一组通用的 x 和 y 轴。我期待每个子图都有独立的轴: import pandas as pd import numpy as np imp
在关于如何制作具有方面和显着性水平的箱线图的许多问题之后,特别是 this和 this ,我还有一个小问题。 我设法生成了如下所示的图,这正是我想要的。 我现在面临的问题是当我很少或没有显着的比较时;
预先感谢您的帮助! 我正在尝试在 matplotlib 中创建箱线图,但在尝试添加标签时出现错误。这是引发错误的代码: df_selected_station_D.boxplot(column='20
我正在使用 Wisconsin dataset 。要显示 Y 轴是数据帧变量(例如:radius_mean)且 X 轴是诊断的箱线图,我执行以下操作: sns.boxplot(x='label', y
我已经为此工作了几个小时,似乎无法做到这一点。箱线图只给我平坦的垂直线,它让我发疯。无论有没有因子函数,我都得到相同的输入 ggplot(df2,aes(x = factor(Location),y=
预先感谢您的帮助! 我正在尝试在 matplotlib 中创建箱线图,但在尝试添加标签时出现错误。这是引发错误的代码: df_selected_station_D.boxplot(column='20
我正在使用 Wisconsin dataset 。要显示 Y 轴是数据帧变量(例如:radius_mean)且 X 轴是诊断的箱线图,我执行以下操作: sns.boxplot(x='label', y
我正在尝试将箱线图中的异常值涂成黑色。我设法将盒子着色为灰色,但我不知道如何为异常值着色。 (图表上的白点) boxplot(y1$Frequency..times., col="grey") 预先感
在 R 中,我试图在 ggplot 中制作一个箱线图,其中翻转坐标(水平框)使用 facets 分组。当我在不翻转坐标的情况下构建它时,ggplot 将在 scales="free"的方面内删除未使用
我是一名优秀的程序员,十分优秀!