Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Re: Re: Does Mathematica do transparent colors?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg31353] Re: [mg31343] Re: Does Mathematica do transparent colors?
  • From: Tomas Garza <tgarza01 at prodigy.net.mx>
  • Date: Tue, 30 Oct 2001 04:35:37 -0500 (EST)
  • References: <9rgfb9$d1q$1@smc.vnet.net> <200110290723.CAA15107@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Ok, I think we can make a small improvement yet. Incidentally, I suggest you
use the Options Fills instead of PlotStyle in FilledPlot in order to control
the shade of Gray. With this change, and using your previous results below,
first take the Rectangle primitives from gr1:


In[1]:=
ff = Cases[gr1,x_/;Head[x]==Rectangle, Infinity];


Now transform your Rectangles into Lines:

In[2]:=
gg = Show[Graphics[Cases[ff, Rectangle[{x1_, x2_},
       {y1_, y2_}] -> Line[{{x1, x2}, {x1, y2}, {y1, y2},
        {y1, x2}}], Infinity]]];

and then pool the two things together:

In[3]:=
Show[gr2, gg, DisplayFunction -> $DisplayFunction];

This, I think, is closer to your goal, although here you get translucent
unfilled rectangles. I guess the color issue, i.e., filling the rectangles
with translucent color, is rather more complicated.

Tomas Garza
Mexico City

----- Original Message -----
From: "Ronald Bruck" <bruck at math.usc.edu>
To: mathgroup at smc.vnet.net
Subject: [mg31353] [mg31343] Re: Does Mathematica do transparent colors?


> [[ 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
> To: mathgroup at smc.vnet.net
> > Subject: [mg31353] [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: Balls
  • Next by Date: weibull distribution
  • Previous by thread: Re: Does Mathematica do transparent colors?
  • Next by thread: Can NDSolve find the other solution???