highcharter:BoxPlot 离群值不在正确的 x 轴点上
highcharter: BoxPlot Outliers not being on correct x-axis point
有一个数据集,我想在 highcharter
中创建一个包含离群值的箱线图。箱线图有效,但我似乎无法在正确的 x-axis
位置获得异常值;由于某种原因,它们都在位置 0 上分组。箱线图是正确的,所以我不确定为什么离群值不遵循箱线图。
下面是我的代码:
library (highcharter)
Quote <- c(12,15,16,12,14,19,13,12,17,15,14,18,22,25,29,30,14,2,5,4)
Other <- c(30,35,36,12,18,35,39,41,42,43,45,31,37,35,32,31,34,36,32,15)
Shop <- c(2,1,5,4,6,9,5,4,7,8,1,5,4,3,5,4,1,5,15,19)
PN <- c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
Dat <- data.frame(Quote,Other,Shop, PN)
highchart() %>%
hc_add_series_boxplot(Dat$Quote, Dat$PN, name = "Quote Hold Time", color = "#FF8888", pointStart = 0) %>%
hc_add_series_boxplot(Dat$Other, Dat$PN, name = "Other Hold Time", color = "#E5A919", pointStart = 1) %>%
hc_add_series_boxplot(Dat$Shop, Dat$PN, name = "Shop Time", color = "#51C1BC", pointStart = 2) %>%
hc_xAxis(categories = c("Quote Hold","Other Hold","Shop Time"), labels = list(enabled = TRUE)) %>%
hc_yAxis(labels = list(format = "{value} days"), min = 0) %>%
hc_plotOptions(series = list(grouping = FALSE))
下面是问题图片。所有 scatter (outliers)
都位于 x 轴上的报价保留类别下。
我想出了一些数据操作,所以所有数据都在一个系列中。我无法弄清楚如何使异常值与给定 x 列中的箱线图颜色相同,但将它们全部变成相同的阴影也可以。
library (highcharter)
Quote <- c(12,15,16,12,14,19,13,12,17,15,14,18,22,25,29,30,14,2,5,4)
Other <- c(30,35,36,12,18,35,39,41,42,43,45,31,37,35,32,31,34,36,32,15)
Shop <- c(2,1,5,4,6,9,5,4,7,8,1,5,4,3,5,4,1,5,15,19)
PN <- c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
Dat <- data.frame(Quote,Other,Shop, PN)
Dat$QuoteType <- rep("Quote",nrow(Dat))
Dat$OtherType <- rep("Other",nrow(Dat))
Dat$ShopType <- rep("Shop",nrow(Dat))
Dat1 <- Dat[,c("Quote","QuoteType")]
colnames(Dat1) <- c("Value","Type")
Dat2 <- Dat[,c("Other","OtherType")]
colnames(Dat2) <- c("Value","Type")
Dat3 <- Dat[,c("Shop","ShopType")]
colnames(Dat3) <- c("Value","Type")
DatComb <- rbind(Dat1,Dat2,Dat3)
highchart() %>%
hc_add_series_boxplot(DatComb$Value, DatComb$Type, colors = c("#FF8888","#E5A919","#51C1BC"), name = "Test") %>%
hc_yAxis(labels = list(format = "{value} days"), min = 0) %>%
hc_plotOptions(boxplot = list(colorByPoint = TRUE), scatter = list(color = c("#A6BBC8")))
有一个数据集,我想在 highcharter
中创建一个包含离群值的箱线图。箱线图有效,但我似乎无法在正确的 x-axis
位置获得异常值;由于某种原因,它们都在位置 0 上分组。箱线图是正确的,所以我不确定为什么离群值不遵循箱线图。
下面是我的代码:
library (highcharter)
Quote <- c(12,15,16,12,14,19,13,12,17,15,14,18,22,25,29,30,14,2,5,4)
Other <- c(30,35,36,12,18,35,39,41,42,43,45,31,37,35,32,31,34,36,32,15)
Shop <- c(2,1,5,4,6,9,5,4,7,8,1,5,4,3,5,4,1,5,15,19)
PN <- c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
Dat <- data.frame(Quote,Other,Shop, PN)
highchart() %>%
hc_add_series_boxplot(Dat$Quote, Dat$PN, name = "Quote Hold Time", color = "#FF8888", pointStart = 0) %>%
hc_add_series_boxplot(Dat$Other, Dat$PN, name = "Other Hold Time", color = "#E5A919", pointStart = 1) %>%
hc_add_series_boxplot(Dat$Shop, Dat$PN, name = "Shop Time", color = "#51C1BC", pointStart = 2) %>%
hc_xAxis(categories = c("Quote Hold","Other Hold","Shop Time"), labels = list(enabled = TRUE)) %>%
hc_yAxis(labels = list(format = "{value} days"), min = 0) %>%
hc_plotOptions(series = list(grouping = FALSE))
下面是问题图片。所有 scatter (outliers)
都位于 x 轴上的报价保留类别下。
我想出了一些数据操作,所以所有数据都在一个系列中。我无法弄清楚如何使异常值与给定 x 列中的箱线图颜色相同,但将它们全部变成相同的阴影也可以。
library (highcharter)
Quote <- c(12,15,16,12,14,19,13,12,17,15,14,18,22,25,29,30,14,2,5,4)
Other <- c(30,35,36,12,18,35,39,41,42,43,45,31,37,35,32,31,34,36,32,15)
Shop <- c(2,1,5,4,6,9,5,4,7,8,1,5,4,3,5,4,1,5,15,19)
PN <- c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
Dat <- data.frame(Quote,Other,Shop, PN)
Dat$QuoteType <- rep("Quote",nrow(Dat))
Dat$OtherType <- rep("Other",nrow(Dat))
Dat$ShopType <- rep("Shop",nrow(Dat))
Dat1 <- Dat[,c("Quote","QuoteType")]
colnames(Dat1) <- c("Value","Type")
Dat2 <- Dat[,c("Other","OtherType")]
colnames(Dat2) <- c("Value","Type")
Dat3 <- Dat[,c("Shop","ShopType")]
colnames(Dat3) <- c("Value","Type")
DatComb <- rbind(Dat1,Dat2,Dat3)
highchart() %>%
hc_add_series_boxplot(DatComb$Value, DatComb$Type, colors = c("#FF8888","#E5A919","#51C1BC"), name = "Test") %>%
hc_yAxis(labels = list(format = "{value} days"), min = 0) %>%
hc_plotOptions(boxplot = list(colorByPoint = TRUE), scatter = list(color = c("#A6BBC8")))