MEVIS3000
MEVIS3000

Reputation: 561

Curious about color code for matplotlib colors

I was wondering what this 1. means in the color code of a matplotlib colormap. These are some viridis colors:

[[ 0.267004  0.004874  0.329415  1.      ]
 [ 0.278826  0.17549   0.483397  1.      ]
 [ 0.229739  0.322361  0.545706  1.      ]
 [ 0.172719  0.448791  0.557885  1.      ]
 [ 0.127568  0.566949  0.550556  1.      ]
 [ 0.157851  0.683765  0.501686  1.      ]
 [ 0.369214  0.788888  0.382914  1.      ]
 [ 0.678489  0.863742  0.189503  1.      ]
 [ 0.993248  0.906157  0.143936  1.      ]]

Generated with:

import matplotlib.pyplot as plt    
import numpy as np

colors = plt.get_cmap('viridis')(np.linspace(0, 1.0, 9))
print colors

The first three numbers of the sublists are obviously just RGB values, but can someone help with the 1. regarding its function.

N.B.: I'm not having any errors, as the title says, I'm just curious about it ;)

Upvotes: 1

Views: 252

Answers (1)

musically_ut
musically_ut

Reputation: 34288

That 1.0 stands for alpha or the opaqueness of the colors. That is the alpha parameter in functions like .to_rgba(arg, alpha=None).

Upvotes: 1

Related Questions