2013-07-19 26 views
1

我一直在使用fill_between來填充圖像中看到的兩條紅線。我一直在使用this example(底部第三位數字)。對樂隊使用fill_between

但是,在我的情況下,我有一個y值的兩個x值。我已經差不多了,但不明白這裏出了什麼問題:

ax = plt.subplot(111) 
plt.ylim(0.1, 1.2) 
plt.xlim(0.03, 5.0) 
ax.fill_between(inner_edge, outer_edge, mass, facecolor='b') 
plt.loglog(inner_edge, mass, 'r-') 
plt.loglog(outer_edge, mass, 'r-') 

爲什麼程序只填充它的一部分。那是什麼扭曲?

enter image description here

回答

3

使用fill_betweenx代替

ax.fill_betweenx(mass, inner_edge, outer_edge, facecolor='b') 

實施例:

import matplotlib.pyplot as plt 
import numpy as np 

inner_edge = np.linspace(0.1, 5.0, 10) 
outer_edge = inner_edge * 0.3 
mass = np.linspace(0.1, 1.2, 10) 

ax = plt.subplot(111) 
plt.ylim(0.1, 1.2) 
plt.xlim(0.03, 5.0) 

ax.fill_betweenx(mass, inner_edge, outer_edge, facecolor='b') 

plt.loglog(inner_edge, mass, 'r-') 
plt.loglog(outer_edge, mass, 'r-') 

plt.show() 

enter image description here

+0

A-M-A-Z-I-N-G !!有效!非常感謝! – Rohit