grr

matplotlib_simple_template.py

f:id:testbot:20210314152221p:plain

import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec

# matplotlib -------------------
plt.style.use("ggplot") # style読込

fig = plt.figure(figsize=(12,8)) # figsize=ウィンドウサイズ
fig.patch.set_facecolor("#fafafa") # 全体背景色

gs = GridSpec(4, 1, height_ratios=[3, 1, 0.8, 1.2]) #縦4個、横1個のグリッドとその表示比率
gs.update(left=0.07,bottom=0.05, right=0.95, top=0.95, hspace=0) #全体の余白

ax0 = plt.subplot(gs[0])
ax0.tick_params(axis="x", bottom=False, labelbottom=False) #x軸目盛とラベルの非表示

ax1 = plt.subplot(gs[1], sharex=ax0)
ax1.spines["top"].set_color("slategray")

ax2 = plt.subplot(gs[2])
ax2.axis("off") #軸の非表示

ax3 = plt.subplot(gs[3], sharex=ax0)
ax3.grid(False)

plt.show()