x <- 1:10

#(1)
x1 <- c(7,4,6,2,9,3,8,1,6,3)
y1 <- c(3,6,5,8,3,4,2,9,2,6)

#(2)
x2 <- c(6,3,4,9,1,8,4,2,5,7)
y2 <- c(7,8,2,1,7,9,6,3,5,4)
d <- data.frame(x1,y1,x2,y2)
summary(data.frame(x1,y1,x2,y2))
##        x1             y1            x2             y2      
##  Min.   :1.00   Min.   :2.0   Min.   :1.00   Min.   :1.00  
##  1st Qu.:3.00   1st Qu.:3.0   1st Qu.:3.25   1st Qu.:3.25  
##  Median :5.00   Median :4.5   Median :4.50   Median :5.50  
##  Mean   :4.90   Mean   :4.8   Mean   :4.90   Mean   :5.20  
##  3rd Qu.:6.75   3rd Qu.:6.0   3rd Qu.:6.75   3rd Qu.:7.00  
##  Max.   :9.00   Max.   :9.0   Max.   :9.00   Max.   :9.00
COL <- c(rgb(255,   0,   0,  105, max = 255), 
         rgb(  0,   0, 255,  105, max = 255),
         rgb(  0, 155,   0,  105, max = 255),
         rgb(155, 255,   0,  105, max = 255))
matplot(x,d, type = 'p',col=COL)

matplot(data.frame(x1,y1,x2,y2), type = 'p',pch = 16, col = COL,
        main = '主タイトル',
        xlab = 'x軸ラベル[単位]',
        ylab = 'y軸ラベル[単位]')

grid()

legend('topleft', col = COL,pch = 16,legend = colnames(d))

matplot(x = x, y = d, type = 'n', 
        ylim = c(-10, 10),
        main = '主タイトル',
        xlab = 'x軸ラベル[単位]',
        ylab = 'y軸ラベル[単位]')


abline(lty = 2,               
       col = gray(0.5, 0.25), 
       h = seq(-10, 10, 5),  
       v = seq(0, 100, 20))   

PCH <- 16:18  
matpoints(x = x, y = d$x1, pch = PCH[1], col = COL[1])
matpoints(x = x, y = d$y1, pch = PCH[2], col = COL[2])
matpoints(x = x, y = d$x2, pch = PCH[3], col = COL[3])
matpoints(x = x, y = d$y2, pch = PCH[4], col = COL[4])
legend('topright', pch = PCH, col = COL, legend = colnames(d))

pairs(d, pch = 16, col = COL[1])
library(plotly)
##  要求されたパッケージ ggplot2 をロード中です
## 
##  次のパッケージを付け加えます: 'plotly'
##  以下のオブジェクトは 'package:ggplot2' からマスクされています:
## 
##     last_plot
##  以下のオブジェクトは 'package:stats' からマスクされています:
## 
##     filter
##  以下のオブジェクトは 'package:graphics' からマスクされています:
## 
##     layout

kyokasho <- list(size = 11, color = 'blue', family = 'UD Digi Kyokasho NK-R')

plot_ly() |>
  add_trace(x = x, y = d$x1, name = 'x1', marker = list(color = COL[1])) |>
  add_trace(x = x, y = d$y1, name = 'y1', marker = list(color = COL[2])) |>
  add_trace(x = x, y = d$x2, name = 'y2', marker = list(color = COL[3])) |>
  add_trace(x = x, y = d$y2, name = 'x2', marker = list(color = COL[4])) |>
  layout(barmode = 'group',
         font  = kyokasho,
         title = '主タイトル',
         xaxis = list(title = 'x軸ラベル[単位]'),
         yaxis = list(title = 'y軸ラベル[単位]', range = c(0, 10)))
## No trace type specified:
##   Based on info supplied, a 'scatter' trace seems appropriate.
##   Read more about this trace type -> https://plotly.com/r/reference/#scatter
## No scatter mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
## No trace type specified:
##   Based on info supplied, a 'scatter' trace seems appropriate.
##   Read more about this trace type -> https://plotly.com/r/reference/#scatter
## No scatter mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
## No trace type specified:
##   Based on info supplied, a 'scatter' trace seems appropriate.
##   Read more about this trace type -> https://plotly.com/r/reference/#scatter
## No scatter mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
## No trace type specified:
##   Based on info supplied, a 'scatter' trace seems appropriate.
##   Read more about this trace type -> https://plotly.com/r/reference/#scatter
## No scatter mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode