x <- 0:9
x1 <- c(7,4,6,2,9,3,8,1,6,3)
y1 <- c(3,6,5,8,3,4,2,9,2,6)
x2 <- c(6,3,4,9,1,8,4,2,5,7)
y2 <- c(7,8,2,1,7,9,6,3,5,4)
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,88,69,155,max=255),
         rgb(163,96,216,155,max=255),
         rgb(77,77,77,77,max=255))
a <- data.frame(
     d1=c(x1,y1),d2=c(x2,y2))
matplot(x=x1,y=y1,type='n',main='散布図',xlab='x',ylab='y',pch=16,col=COL)
matpoints(x=x1,y=y1,pch=16,col=COL[1],cex=2)
matpoints(x=x2,y=y2,pch=16,col=COL[2],cex=2)
grid()
legend(x=6.2,y=10.08,pch=10,col=COL,legend=a,cex=0.5,par(xpd=TRUE))
## Warning in rect(left, top, r, b, angle = angle, density = density, ...):
## 与えられた色が数値でも文字列でもありません

## Warning in rect(left, top, r, b, angle = angle, density = density, ...):
## 与えられた色が数値でも文字列でもありません

matplot(x=x1,y=y1,type = 'n', 
        ylim = c(-0,10),
        main = '散布図(出版品質)',
        xlab = 'x',
        ylab = 'y')
abline(lty = 2,             
       col = gray(0.5, 0.25), 
       h = seq(-10, 10, 1), 
       v = seq(0,100,1))
matpoints(x=x1,y=y1,pch=16,col=COL[1],cex=2.4)
matpoints(x=x2,y=y2,pch=16,col=COL[2],cex=2.4)
legend(x=6.2,y=10.08,pch=10,col=COL,legend=a,cex=0.5,par(xpd=TRUE))
## Warning in rect(left, top, r, b, angle = angle, density = density, ...):
## 与えられた色が数値でも文字列でもありません

## Warning in rect(left, top, r, b, angle = angle, density = density, ...):
## 与えられた色が数値でも文字列でもありません

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 =x1,y= y1, name ='x1y1', marker = list(color = COL[1],cex=3)) |>
  add_trace(x =x2,y= y2, name ='x2y2', marker = list(color = COL[2],cex=3)) |>
  layout(barmode = 'group',
         font  = kyokasho,
         title = '散布図',
         xaxis = list(title = 'x'),
         yaxis = list(title = 'y',range = c(0, 10),marker=list(size=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