プロットの下に赤い括弧を作成する方法について質問に答えましょう。基本的には、ブラケットの形で線をプロットし、x軸変換に従って配置することができます。以下はそれを行う関数です。
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
ax.bar(range(-1,5),range(3,9), width=1, align="edge", ec="k", alpha=1)
ax.set_xticks(range(1,6))
def bracket(ax, pos=[0,0], scalex=1, scaley=1, text="",textkw = {}, linekw = {}):
x = np.array([0, 0.05, 0.45,0.5])
y = np.array([0,-0.01,-0.01,-0.02])
x = np.concatenate((x,x+0.5))
y = np.concatenate((y,y[::-1]))
ax.plot(x*scalex+pos[0], y*scaley+pos[1], clip_on=False,
transform=ax.get_xaxis_transform(), **linekw)
ax.text((0.5+pos[0])*scalex, (y.min()-0.01)*scaley+pos[1], text,
transform=ax.get_xaxis_transform(),
ha="center", va="top", **textkw)
bracket(ax, text="0", pos=[-1,-0.01], linekw=dict(color="crimson", lw=2))
plt.show()
![enter image description here](https://i.stack.imgur.com/UiMz3.png)
そして、 "それをyorself描きます" – abukaj