[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Graph background color
Friedrich Huebler <firstname.lastname@example.org> notes that he can see very thin
lines in the original background color for a scheme at the top and bottom of
his graphs, even though he has changed the graphregion color. He wants to get
rid of these.
> The s2color scheme contains the line "color background
> ltbluishgray". The s2mono scheme contains the line "color
> background gs15". This background color is visible in faint lines
> around the graphregion when the graphregion is set to a color
> different from the background.
> . sysuse auto
> . set scheme s2color
> . graph bar mpg, graphregion(color(white))
> The resulting bar graph has fine horizontal lines in the color
> "ltbluishgray" at the top and bottom of the graphregion.
> Is there a command for changing the background color in a graph or
> can this color only changed through a scheme?
> I would like to add another question. Is it possible to expand the
> graph region so that it covers the available area of the graph
> completely? This would make it unnecessary to change the background
This may not be of much interested to Friedrich, but the graph region believes
it does completely cover the available area of the graph. What is happening
is that in the knife edge computation of trying to draw a bounding (graph
region) box of an exact size the computations are off by just enough so that
the rendering device decides that it needs to add a full pixel for the
infinitesimal difference in the overall graph size and the graph region size.
The two are rendered in different metrics and that is why there may be an
I have two suggestions. The best thing is probably to specify a somewhat
larger line width when drawing the graph region. This forces the graph region
to actually appear larger than it is by half the width of the line. In
Friedrich's example the command would become
> . graph bar mpg, graphregion(color(white) lwidth(large))
Friedrich noted that setting -lwidth()- did not work for him. The results may
differ ever so slightly by device, but this works on the screens and printers
I have tried.
Another possibility is to use the undocumented -bgcolor(<colorstyle>)- option.
This really does reset the background color of the graph. More correctly, it
resets the background color of the graphics device context, and that is both
important and the reason we did not document -bgcolor()-. Whereas Stata will
allow you to -graph combine- graphs with different background colors and it
will respect those colors (unless you request differently using
-commonscheme-), there is only ONE device context background color. What this
means is that the background color set by -bgcolor()- will not, and indeed
cannot, be respected by -graph combine-. Also, if you are going to specify
-bgcolor(white)-, you must still specify -graphregion(color(white))- or the
region color will still overlay the background.
We will look into whether some defaults can be set differently to reduce the
chance that the background color shows through at some edges.
* For searches and help try: