Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2f671e4

Browse filesBrowse files
committed
DOC: Update color tutorial to explain alpha
1 parent baa5f8e commit 2f671e4
Copy full SHA for 2f671e4

File tree

Expand file treeCollapse file tree

1 file changed

+14
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-1
lines changed

‎tutorials/colors/colors.py

Copy file name to clipboardExpand all lines: tutorials/colors/colors.py
+14-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.