Set alpha channel for pyplot objects?

In R, you can set the alpha channel to

rgb(r=.1,g=.5,b=.5,alpha=.5,max=1) 

for any object that takes a color argument. patch objects in pyplot have a set_alpha method, but can this be done for lines in a graph, for example? e.g. pyplot.plot(x,y,color=???) or h = pyplot.plot(x,y) and do something with h .

+4
source share
2 answers

plt.plot(x,y,'ro-',alpha=0.3)

if you want to mix your own color you can pass the hex value or rgb tuple http://matplotlib.sourceforge.net/api/colors_api.html

+6
source

A message appears stating that

 h = plt.plot(x,y) 

returns a list of matplotlib.lines.Line2D objects in h , even if there is one element, so h[0].set_alpha() is the method used.

+3
source

Source: https://habr.com/ru/post/1385659/


All Articles