d0 <- read.csv(file='C:/Users/shiro/Downloads/electric_power.csv')
d <- data.frame(y1=d0$y1,y2=d0$y2)
rownames(d) <- d0$X
px <- as.POSIXct(d0$X)
nr <- nrow(d) 
nc <- ncol(d)
COL <- c(rgb(255,   0,   0,  255, max = 255),
         rgb(  0,   0, 255,  255, max = 255), 
         rgb(  0, 155,   0,  255, max = 255)) 
library(DT)
datatable(d, caption = "正規乱数の時系列データ")
matplot(x=px,y=d,type="l")

matplot(x = px, y = d, type = "o", pch = colnames(d))

matplot(x = px, y = d, type = "o", pch = 1:nc, xlab = "2021", ylab = "値")

grid()

legend("bottomright", legend = colnames(d), pch = 1:nc, lty = 1:nc, col = 1:nc)

matplot(x = px,   
        y = d,            
        type = "n",        
        xaxt = "n",       
        ylim = c(2000,3000),
        main = "主タイトル",
        xlab = "x軸 ラベル [単位]",
        ylab = "y軸 ラベル [単位]")
px.g <- seq(px[1], px[nr], by = 60*60*24*2)
axis(side = 1, at = px.g, labels = format(px.g, "%b/%d(%a)"))

abline(lty = 2,             
       col = gray(0.5, 0.25), 
       h   = seq(2000,3000, 200), 
       v   = px.g)            
matlines(x = px, y = d$y1, type = "o", pch = 1, lty = 1, col = COL[1])
matlines(x = px, y = d$y2, type = "o", pch = 2, lty = 2, col = COL[2])
legend("topright", col = COL, pch = 1:nc, lty = 1:nc, legend = colnames(d))

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(mode = "lines+markers") |>
  add_trace(x = px, y = d$y1, name = "y1") |>
  add_trace(x = px, y = d$y2, name = "y2") |>
  config(locale = "ja") |> 
  layout(font = kyokasho,
         title = "主タイトル",
         xaxis = list(title = "x軸ラベル[単位]"),
         yaxis = list(title = "y軸ラベル[単位]"))
## 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 trace type specified:
##   Based on info supplied, a 'scatter' trace seems appropriate.
##   Read more about this trace type -> https://plotly.com/r/reference/#scatter
import pandas as pd
d=pd.read_csv('C:/Users/shiro/Downloads/electric_power.csv')
d = d.rename(columns = {'Unnamed: 0': 'px'}) 
d['px'] = pd.to_datetime(d['px'])
d = d.set_index('px')
print(d)
##                        y1    y2
## px                             
## 2021-05-01 00:00:00  2164  2162
## 2021-05-01 01:00:00  2065  2065
## 2021-05-01 02:00:00  2064  2061
## 2021-05-01 03:00:00  2102  2081
## 2021-05-01 04:00:00  2114  2086
## 2021-05-01 05:00:00  2064  2072
## 2021-05-01 06:00:00  2030  2086
## 2021-05-01 07:00:00  2127  2186
## 2021-05-01 08:00:00  2334  2319
## 2021-05-01 09:00:00  2492  2430
## 2021-05-01 10:00:00  2619  2472
## 2021-05-01 11:00:00  2667  2609
## 2021-05-01 12:00:00  2570  2543
## 2021-05-01 13:00:00  2465  2554
## 2021-05-01 14:00:00  2538  2575
## 2021-05-01 15:00:00  2562  2594
## 2021-05-01 16:00:00  2508  2673
## 2021-05-01 17:00:00  2596  2801
## 2021-05-01 18:00:00  2737  2911
## 2021-05-01 19:00:00  2717  2881
## 2021-05-01 20:00:00  2592  2780
## 2021-05-01 21:00:00  2462  2625
## 2021-05-01 22:00:00  2330  2451
## 2021-05-01 23:00:00  2235  2303
import matplotlib.pyplot as plt
import matplotlib.dates as mdates

plt.gca().xaxis.set_major_formatter(
  mdates.DateFormatter("%b/%d (%a)"))

plt.gca().xaxis.set_major_locator(
  mdates.DayLocator(interval = 2))

plt.xticks(fontsize = 10,font='MS Gothic')
## (array([1.]), [Text(1.0, 0, '1/02 (金)')])
plt.title('主タイトル',font='MS Gothic')
plt.xlabel('x軸ラベル[単位]',font='MS Gothic')
plt.ylabel('y軸ラベル[単位]',font='MS Gothic')

plt.grid(linestyle = '--', color = (0.9, 0.9, 0.9, 0.25))

plt.plot(d['y1'], label = 'y1', marker = 'o', linestyle = 'solid')
plt.plot(d['y2'], label = 'y2', marker = '^', linestyle = 'dotted')

plt.legend(loc = 'lower right',fontsize=10,prop={'family':'MS Gthic'})

plt.show()
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.
## findfont: Font family 'MS Gthic' not found.