2013-04-07 4 views

답변

4

당신은하기 matplotlib 음모에 색 영역은 collections.BrokenBarHCollection를 사용 할 수 있습니다

import matplotlib.pyplot as plt 
import matplotlib.collections as collections 

fig = plt.figure() 
ax = fig.add_subplot(111) 

# Plot your own data here 
x = range(0, 30000) 
y = range(0, 30000) 
ax.plot(x, y) 

xrange = [(0, 30000)] 
yrange1 = (0, 15000) 
yrange2 = (15000, 23000) 
yrange3 = (23000, 30000) 

c1 = collections.BrokenBarHCollection(xrange, yrange1, facecolor='blue', alpha=0.5) 
c2 = collections.BrokenBarHCollection(xrange, yrange2, facecolor='green', alpha=0.5) 
c3 = collections.BrokenBarHCollection(xrange, yrange3, facecolor='red', alpha=0.5) 

ax.add_collection(c1) 
ax.add_collection(c2) 
ax.add_collection(c3) 

plt.show()