This code generates a curve in R using pwr and ggplot2 packages. How can I change the color of this curve?
library(pwr)
library(ggplot2)
P0 = c(0.05,0.06,0.11,0.104,0.16,0.106,0.01,0.1,
0.1,0.1,0.08,0.02)
P1 = c(0.1,0.05,0.12,0.101,0.12,0.105,0.024,0.04,
0.01,0.11,0.04,0.06)
effect.size = ES.w1(P0, P1)
degrees = length(P0) - 1
pwr.chisq.test(
w=effect.size,
N=NULL,
df=degrees,
power=0.80,
sig.level=0.05)
P.out <- pwr.chisq.test(
w=effect.size,
N=NULL,
df=degrees,
power=0.80,
sig.level=0.05)
plot(P.out)
p <- plot(P.out)
p + theme_classic(base_size = 14)
Add color info in this way:
plot(P.out)+
geom_line(colour="blue")

With the same command you can also use HTML color code, like this:
geom_line(colour="#2E64FE")
The color red seems to be hard coded in the pwr::plot.power.htest function. However you can edit the ggplot object that's returned in somewhat of a hacky way to get the job done
p <- plot(P.out)
p$layers[[1]]$aes_params$colour <- "blue"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With