我正试图用matplotlib填充曲线下的区域.下面的脚本运行正常.
import matplotlib.pyplot as plt
from math import sqrt
x = range(100)
y = [sqrt(i) for i in x]
plt.plot(x,y,color='k',lw=2)
plt.fill_between(x,y,0,color='0.8')
plt.show()
Run Code Online (Sandbox Code Playgroud)
但是,如果我将y标度设置为对数(见下文).它有时会填满曲线上方的区域!谁能帮我?我想填充曲线和y = 0之间的区域.
x = range(100)
y = [sqrt(i) for i in x]
plt.plot(x,y,color='k',lw=2)
plt.fill_between(x,y,0,color='0.8')
plt.yscale('log')
plt.show()
Run Code Online (Sandbox Code Playgroud)
提前致谢!