Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
347 views
ubuntu2004
Kernel: R (system-wide)
library(openxlsx) Data <- read.xlsx(paste(getwd(), "/8-1.xlsx", sep=""), startRow=5, colNames=FALSE) names(Data)
[1] "X1" "X2" "X3" "X4" "X5" "X6" "X7" "X8" "X9" "X10" "X11" "X12" [13] "X13" "X14" "X15" "X16" "X17" "X18" "X19" "X20" "X21" "X22" "X23" "X24" [25] "X25" "X26" "X27" "X28" "X29" "X30" "X31" "X32"
plotP_L = function(x, y, xlab, ylab, by, xlim, ylim) { x <- x[!is.na(x)] y <- y[!is.na(y)] sp <- splinefun(x, y) xest <- seq(min(x), max(x), by = by) yest <- sp(xest) plot(x, y, type="p",col="black", xlab=xlab, ylab=ylab, xlim=xlim, ylim=ylim) par(new=T) plot(xest, yest, type="l", col="black", xlab="", ylab="" , axes=FALSE, xlim=xlim, ylim=ylim, xaxt="n", yaxt="n") }
x1 <- Data$"X5" y1 <- Data$"X4" x2 <- Data$"X13" y2 <- Data$"X12" plotP_L(x1, y1, "V2", "If2", 10, c(0, 270), c(0, 2.1)) par(new =T) plotP_L(x2, y2, "", "", 10, c(0, 270), c(0, 2.1))
Image in a Jupyter notebook
x1 <- Data$"X4"[0:18] y1 <- Data$"X5"[0:18] x2 <- Data$"X28"[0:15] y2 <- Data$"X30"[0:15] mai <- par()$mai #余白サイズの設定(上下と左右の幅を揃える) mai[4] <- mai[1] par(mai=mai) plot(x2, y2, xlab="", ylab="", xlim=c(0, 2), ylim=c(0, 20), pch=3) m <- lm(y2~x2) abline(m) par(new=T) plot(x1, y1, xaxt="n", yaxt="n", xlab="If", ylab="E0", xlim=c(0, 2), ylim=c(0,300), pch=2) result <- nls(y1 ~ (a*x1^2 + b*x1 + c), start = c(a=0, b=0, c=0)) predict.c = predict(result) par(new=T) plot(x1, predict.c, type="l", xaxt="n", yaxt="n", xlab="", ylab="", xlim=c(0, 2), ylim=c(0,300)) axis(4) mtext("Is", #2軸目のラベル名 side = 4, #どこにラベルを置くか(1なら下,2なら左,3なら上,4なら右) line = 2 #グラフの枠からの距離 ) legend("topleft", legend = c("E0","Is"), pch=c(2,3)) # a <- predict(result) # a <- a[2:length(a)] # m <- predict(m) # m <- m[2:length(m)] # y3 <- a / m # par(new=T) # plot(x1[2:length(x1)], y3, type="l")
Image in a Jupyter notebook