segmentation labels are siplayed incorrectly in python

hello, I am trying to segment the lung (label 1,purple) and lung opacities (label 2,yellow) from ct scan images. after I finish segmenting in the slicer I save the labels as a nifti file. when I try to visualize the segmented areas in jupyter notebook label 1 and label 2 segments are mixed up. I mean that for some of the slices label 1 is displayed as purple and for others label 2 is displayed as purple. I run the following code in jupyter:

data = nib.load(sample_path)
label = nib.load(sample_path_label)

ct = data.get_fdata()
mask = label.get_fdata().astype(int)

fig = plt.figure()
camera = Camera(fig) # Create the camera object from celluloid

for i in range(ct.shape[2]): # Axial view
plt.imshow(ct[:,:,i], cmap=“bone”)
mask_ =[:,:,i]==0, mask[:,:,i])
plt.imshow(mask_, alpha=0.5)
# plt.axis(“off”)
camera.snap() # Store the current slice
animation = camera.animate() # Create the animation