How to plot a 95 percent and 5 percent chart on a ggplot2 chart with already calculated values?

I have this dataset and use this R code:

library(reshape2)
library(ggplot2)
library(RGraphics)
library(gridExtra)

long <- read.csv("long.csv")
ix <- 1:14

ggp2 <- ggplot(long, aes(x = id, y = value, fill = type)) +
    geom_bar(stat = "identity", position = "dodge") +
    geom_text(aes(label = numbers), vjust=-0.5, position = position_dodge(0.9), size = 3, angle = 0) +
    scale_x_continuous("Nodes", breaks = ix) +
    scale_y_continuous("Throughput (Mbps)", limits = c(0,1060)) +
    scale_fill_discrete(name="Legend",
                        labels=c("Inside Firewall (Dest)",
                                 "Inside Firewall (Source)",
                                 "Outside Firewall (Dest)",
                                 "Outside Firewall (Source)")) +
    theme_bw() +
    theme(legend.position="right") +
    theme(legend.title = element_text(colour="black", size=14, face="bold")) +
    theme(legend.text = element_text(colour="black", size=12, face="bold")) +
    facet_grid(type ~ .) +
plot(ggp2)

to get the following result: enter image description here

Now I need to add 95 percent and 5 percentiles to the plot. Numbers are computed into this dataset (NFPnumber (95 percent) and FPnumbers (5 percent) columns).

It seems boxplot()to work here, but I'm not sure how to use it with ggplot. stat_quantile(quantiles = c(0.05,0.95))may work, but the function calculates the numbers themselves. Can i use my numbers here?

I also tried:

geom_line(aes(x = id, y = long$FPnumbers)) +
geom_line(aes(x = id, y = long$NFPnumbers))

but the result did not look good enough.

geom_boxplot() doesn't work either:

geom_boxplot(aes(x = id, y = long$FPnumbers)) +
geom_boxplot(aes(x = id, y = long$NFPnumbers))
+4
2

, geom_errorbar - :

ggp2 + geom_errorbar(aes(ymax = NFPnumbers, ymin = FPnumbers), alpha = 0.5, width = 0.5)

enter image description here

, .

+2

boxplot, ymin ymax. , .

ggplot(long, aes(x = factor(id), y = value, fill = type)) +
  geom_boxplot(aes(lower = FPnumbers, middle = value, upper = NFPnumbers, ymin = FPnumbers*0.5, ymax = NFPnumbers*1.2, fill = type), stat = "identity") +
  xlab("Nodes") +
  ylab("Throughput (Mbps)") +
  scale_fill_discrete(name="Legend",
                      labels=c("Inside Firewall (Dest)", "Inside Firewall (Source)",
                               "Outside Firewall (Dest)", "Outside Firewall (Source)")) +
  theme_bw() +
  theme(legend.position="right",
        legend.title = element_text(colour="black", size=14, face="bold"),
        legend.text = element_text(colour="black", size=12, face="bold")) +
  facet_grid(type ~ .)

:

enter image description here


value, FPnumbers NFPnumbers. FPnumbers NFPnumbers 5 95 , , value. min max "Node". , - .

, , , FPnumbers NFPnumbers. 0.5 1.2 . min max.

+1

Source: https://habr.com/ru/post/1534771/


All Articles