플롯의 순서에 산책로를 페이딩가 특정 할 수의 경우 .set_alpha()
방법을 사용하여 플롯 항목의 알파 값을 변경하는 것입니다 달성하기 위해 다른 방법 당신이 사용하고있는 플로팅 방법.
사용중인 특정 플로팅 기능의 출력 (즉, '처리'을 플롯에 추가)을 목록에 추가하면됩니다. 그런 다음 새 플롯을 만들기 전에 해당 목록에있는 기존 항목의 알파 값을 찾아서 줄일 수 있습니다.
다음 예제에서 알파 값이 특정 지점을 벗어난 항목은 .remove()
을 사용하여 플롯에서 제거 된 다음 해당 핸들이 목록에서 제거됩니다.
import pylab as pl
#Set a decay constant; create a list to store plot handles; create figure.
DECAY = 2.0
plot_handles = []
pl.figure()
#Specific to this example: store x values for plotting sinusoid function
x_axis=pl.linspace(0 , 2 * pl.pi , 100)
#Specific to this example: cycle 50 times through 16 different sinusoid
frame_counter = 0
for phase in pl.linspace(0 , 2 * pl.pi * 50 , 16 * 50):
#Reduce alpha for each old item, and remove
for handle in plot_handles:
alpha = handle.get_alpha()
if alpha/DECAY > 0.01 :
handle.set_alpha(alpha/DECAY)
else:
handle.remove()
plot_handles.remove(handle)
#Add new output of calling plot function to list of handles
plot_handles += pl.plot(pl.sin(x_axis + phase) , 'bo')
#Redraw figure
pl.draw()
#Save image
pl.savefig('frame_' + str(frame_counter).zfill(8) + '.png')
frame_counter += 1