matplotlibで領域に色を付けてみたのでメモ。 fill_between関数fill関数を使うと大体できます。 sin(x)とcos(x)の間の領域に色を付ける。 まずはsin(x)とcos(x)の間に色を付けてみます。 fill_betweenは3つの変数を取ります。 x: x軸の範囲指定 y1,y2: この2つの間を塗りつぶす あとはオプションでfacecolorは色、alphaは透過度なんかを指定できます。 import numpy as np import matplotlib.pyplot as plt from math import * x = np.arange(0,10,0.01) y1 = np.sin(x) y2 = np.cos(x) plt.fill_between(x,y1,y2,facecolor='y',alpha=0.5) plt.show() 条件
![matplotlibで領域の図示 - 気ままに宙をみる](https://cdn-ak-scissors.b.st-hatena.com/image/square/596664d5bfe92ffa43c4189c29fa9f220d436e77/height=288;version=1;width=512/http%3A%2F%2Fcdn-ak.f.st-hatena.com%2Fimages%2Ffotolife%2Fc%2Fcranethree%2F20150725%2F20150725200210.png)