From: Fernando P. <fpe...@gm...> - 2009-06-06 02:56:51
|
Hi all, Hopefully the code below is illustrative and commented enough to clarify my question (also attached if you prefer to download it than to copy/paste). Cheers, f """LineCollection ignores alpha value? The second figure below works, but it sets alpha globally for the whole collection. If LineCollection accepts rgbA tuples, why does it ignore the alpha channel? Is it possible somehow to have alpha for each line (without having to make a single-line collection each time? """ from matplotlib import pyplot as plt from matplotlib.collections import LineCollection # Make two lines line0 = [(0,0),(1,1)] line1 = [(1,0),(0,1)] lines = [line0,line1] # Make colors for each. Note alpha is 0.2, so they should be fairly faint, the # red one is meant to be darker than the blue one alpha = 0.2 colors = [(0,0,1,alpha), # blue line (1,0,0,2*alpha)] # red line # Make a figure with these f = plt.figure() ax = f.add_subplot(111) lc = LineCollection(lines,10,colors) ax.add_collection(lc) # Another figure, where we set the alpha globally for the line collection f = plt.figure() ax = f.add_subplot(111) lc = LineCollection(lines,10,colors) lc.set_alpha(alpha) ax.add_collection(lc) plt.show() |