MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Does Mathematica do transparent colors?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg31343] Re: Does Mathematica do transparent colors?
  • From: Ronald Bruck <bruck at math.usc.edu>
  • Date: Mon, 29 Oct 2001 02:23:28 -0500 (EST)
  • References: <9rgfb9$d1q$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

[[ This message was both posted and mailed: see
   the "To," "Cc," and "Newsgroups" headers for details. ]]

Yes, this is pretty much what I had in mind, except that I used color
and GeneralizedBarChart (so I could make the bars full-width).  Here
was my hack:

Needs["Graphics`Graphics`"];
Needs["Statistics`ContinuousDistributions`"];
Needs["Graphics`Colors`"];
Needs["Graphics`FilledPlot`"];

gr[a_] := GeneralizedBarChart[Table[{n - 1, a[[n]], 1}, {n,
  Length[a]}], PlotRange -> All, DisplayFunction -> Identity];
grbin[n_, p_] := gr[Table[Binomial[n, k]p^k(1 - p)^(n - k), {k, 0, n}]];

p = 0.5;
n = 20;
mu = p*n;
sigma = Sqrt[n*p*(1 - p)];
gr1 = grbin[n, p]; 
gr2 = FilledPlot[PDF[NormalDistribution[mu, sigma], x], {x, 0, n}, 
    PlotStyle -> {SlateGrayLight}, PlotRange -> All, 
    DisplayFunction -> Identity];
Show[gr2, gr1, DisplayFunction -> $DisplayFunction];
Show[gr1, gr2, DisplayFunction -> $DisplayFunction]

There's no spacing between the bars in this version (hence their
heights really are their areas), and the region under the normal
distribution is light slate gray.  (Or grey :-)  

Now the second of these two plots would be acceptable IF the gray were
translucent, so the bars could be made out under the gray.  Then you'd
be able to see undershoot and overshoot, and the cancellation effects.

(With n = 20 you won't see the effect of missing half of the first and
last bar.)

Translucency does have a role.  I don't remember the details of Display
Postscript, which was used on the original NeXT machines, but didn't it
have degrees of transparency?  In which case, I have to wonder why wri
didn't implement it then.  They still have the best-looking graphics.

Anyway, I didn't see any way to do it, and this confirms my guess: 
it's not possible.  This is something which Wolfram should add.  Mac OS
X makes use of translucency to a considerable extent--perhaps OVERuses
it--but while I was never a fan of the "look" before, I must say it is
rather attractive the way it's done in Aqua.  And there are some
situations (e.g. 3D objects) where, in the absence of the ability to
grab and rotate, it's quite important.

--Ron Bruck



In article <9rgfb9$d1q$1 at smc.vnet.net>, <"tgarza01 at prodigy.net.mx">
wrote:

> I see your point, and my first guess is that you are asking for something
> which, if not too difficult, it takes a lot of labor, and may not be
> worthwhile. A single graphics object has to be constructed out of two
> different ones, in order to attain that "translucency" you want. When you use
> Show[a1,a2] to display two plots, even with colors that look very
> transparent, a1 overrides whatever happens to be beneath. But I wonder if the
> following appoach could be useful to you:
> 
> In[1]:=
> <<Graphics`Graphics`;
> <<Statistics`ContinuousDistributions`;
> <<Statistics`DiscreteDistributions`;
> <<Graphics`FilledPlot`;
> In[3]:=
> bern=BinomialDistribution[10,0.5];
> norm=NormalDistribution[6,Sqrt[2.5]];
> In[5]:=
> bc=BarChart[Transpose[{Table[PDF[bern,j],{j,0,10}],Range[0,10]}],
>       BarStyle->GrayLevel[0.9],DisplayFunction->Identity];
> In[6]:=
> fp=FilledPlot[PDF[norm,x],{x,0,11},DisplayFunction->Identity];
> In[7]:=
> Show[fp,bc,DisplayFunction->$DisplayFunction];
>   
> This, I'm afraid, is as good as it gets, unless you want to do a good deal of
> tampering with the graphics objects.
> 
> Tomas Garza
> Mexico City
> 
> Original Message:
> -----------------
> From: Ronald Bruck bruck at math.usc.edu
To: mathgroup at smc.vnet.net
> Subject: [mg31343]  Does Mathematica do transparent colors?
> 
> 
> Subject says it all.  I'd like to have translucent colors, so that I
> can see one object underneath another.  Is there any way to do this in
> Mathematica?
> 
> For example, I'd like to plot a bar chart of e.g. a binomial
> distribution and overlay it with a filled plot of the corresponding
> normal distribution--but still be able to see the bars, underneath.
> 
> --Ron Bruck
> 
> --------------------------------------------------------------------
> mail2web - Check your email from the web at
> http://mail2web.com/ .


  • Prev by Date: Re: Unwanted color in postscript output
  • Next by Date: Find variables in a very long expression?
  • Previous by thread: Re: RE: Does Mathematica do transparent colors?
  • Next by thread: Re: Re: Does Mathematica do transparent colors?