-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
MEP28
.. contents:: Table of Contents
.. author:: Michiel de Hoon
.. date:: July 11, 2015
Discussion
None so far.
To set the transparency (alpha component) of a graphics context, either gc.set_alpha(alpha) or gc.set_foreground(rgba, isRGBA=True) can be used. Currently, gc.set_alpha(alpha) forces the alpha value, meaning that gc.set_foreground(rgba, isRGBA=True) will ignore the alpha value of rgba if alpha was previously set through gc.set_alpha. Forcing alpha adds complexity to GraphicsContextBase as well as to the Cairo and MacOSX backends, in which this behavior is partially implemented.
Calls to gc.set_alpha are made in:
- In lib/matplotlib/image.py, in the
drawmethods of_AxesImageBase,PcolorImage,FigureImage, andBboxImage; - In lib/matplotlib/lines.py, in the
drawmethod ofLine2D(five calls total); - In lib/matplotlib/patches.py, in the
drawmethods ofPatchandFancyArrowPatch; - In lib/matplotlib/patheffects.py, in the
draw_pathmethods ofSimplePatchShadowandSimpleLineShadow; - In lib/matplotlib/text.py, in the
drawmethod ofText; - In lib/mpl_toolkits/axisartist/axis_artist.py, in the
drawmethod ofBezierPathandTicks.
Note that these do not necessarily rely on the fact that gc.set_alpha(alpha) overrides gc.set_foreground(rgba); this remains to be verified.
- Review the current usage of
gc.set_alphaand make the required changes, if any; - Remove the
_forced_alphasections from GraphicsContextBase, RendererCairo, GraphicsContextCairo, RendererMac, GraphicsContextMac, and _macosx.GraphicsContext.
The proposal changes the graphics context, which is part of the internal API of matplotlib and is not expected to affect end users.