Graphics Reference
In-Depth Information
that is tocombine the legend with the plot in such a way that the legend output com-
pletely replaces the plot output over the region that the legend is drawn. Figure .
showshowjustdrawingthelegendontopoftheplotproducesthewrongresult(there
are grid lines visible behind the legend). Using an opaque background in the legend
does the job as long as we can anticipate the background colour that the overall plot
willbedrawnon(Fig. . ).However,thisisnotagoodgeneralsolutionbecauseit
fails badly if a different background colour is encountered (Fig. . ). A general solu-
tioninvolves morecompleximagemanipulations, suchasnegating thealphachannel
Figure . . Composing graphical elements on a grey background to show that the use of an opaque
background for a legend (as in Fig. . ) is not suitable if the background of the final image is a different
colour. here are three elements being composed: two legends, one with a transparent background and
one with a white background (top let in Fig. . ), and a plot with a transparent background (top right
in Fig. . ). In the top let in this figure, the legend with a white background is drawn over the plot and
the grid lines in the plot are not visible behind the legend, but the white background of the legend does
not match the background of the plot, so the result is unpleasant. In the top right,thelegendwith
a transparent background has had its alpha channel (opacity) negated, so that the background is the
only part that is opaque. In the bottom let,thenegatedlegendiscompositedwiththeplot using an 'out'
operator, thereby creating a 'hole' in the plot.Inthebottom right, the (untransformed) legend with
a transparent background is drawn over the plot with a hole and the grid lines in the plot are not visible
behind the legend, but the background of the final image is still grey, which is the desired result
Search WWH ::




Custom Search