Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f433e2c

Browse files
authored
Merge pull request #9959 from jklymak/doc-define-alpha
DOC: Update color tutorial to explain alpha
2 parents 4e47f87 + 78fa669 commit f433e2c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tutorials/colors/colors.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Matplotlib recognizes the following formats to specify a color:
77
88
* an RGB or RGBA tuple of float values in ``[0, 1]`` (e.g., ``(0.1, 0.2, 0.5)``
9-
or ``(0.1, 0.2, 0.5, 0.3)``);
9+
or ``(0.1, 0.2, 0.5, 0.3)``). RGBA is short for Red, Green, Blue, Alpha;
1010
* a hex RGB or RGBA string (e.g., ``'#0F0F0F'`` or ``'#0F0F0F0F'``);
1111
* a string representation of a float value in ``[0, 1]`` inclusive for gray
1212
level (e.g., ``'0.5'``);
@@ -23,6 +23,19 @@
2323
the indexing occurs at artist creation time and defaults to black if the
2424
cycle does not include color.
2525
26+
"Red", "Green" and "Blue", are the intensities of those colors, the combination
27+
of which span the colorspace.
28+
29+
How "Alpha" behaves depends on the ``zorder`` of the Artist. Higher
30+
``zorder`` Artists are drawn on top of lower Artists, and "Alpha" determines
31+
whether the lower artist is covered by the higher.
32+
If the old RGB of a pixel is ``RGBold`` and the RGB of the
33+
pixel of the Artist being added is ``RGBnew`` with Alpha ``alpha``,
34+
then the RGB of the pixel is updated to:
35+
``RGB = RGBOld * (1 - Alpha) + RGBnew * Alpha``. Alpha
36+
of 1 means the old color is completely covered by the new Artist, Alpha of 0
37+
means that pixel of the Artist is transparent.
38+
2639
All string specifications of color, other than "CN", are case-insensitive.
2740
2841
"CN" color selection

0 commit comments

Comments
 (0)