Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Primitive Disk Gradient Fills in Graphics

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111003] Re: Primitive Disk Gradient Fills in Graphics
  • From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
  • Date: Fri, 16 Jul 2010 05:18:53 -0400 (EDT)

Hi all,

just clear the protection attributes of ChartElementData and find out
that

ChartElementData["GradientBubble", "Manipulate"]

should help.

Cheers
Patrick

On Thu, 2010-07-15 at 03:10 -0400, David Park wrote:
> Well, darn if there isn't a method for doing that within BubbleChart.
> Evaluate
> 
> ChartElementData["BubbleChart"] 
> 
> {Bubble,FadingBubble,GradientBubble,MarkerBubble,NoiseBubble,OscillatingBubb
> le,PolyhedronBubble,SphereBubble,SquareWaveBubble,TriangleWaveBubble}
> 
> for the various types of bubbles. Then, for example:
> 
> BubbleChart[RandomReal[1, {10, 3}],
>  ChartStyle -> "Pastel",
>  ChartElementFunction -> "GradientBubble"] 
> 
> But how would we obtain different colors for the bubbles, say based on the
> radius? I don't know where we can feed it in.
> 
> Instead of starting with high level, "set-piece" plot types, and then trying
> to screw them around with convoluted options, it would be much easier to
> start with primitives and build up the higher level plot types.
> 
> Suppose I want a bubble fading from White to a color at the rim, and I want
> different colors depending on the radius of the bubble? Here is an easy way
> to build it up.
> 
> Needs["Presentations`Master`"]
> 
> First define the primitive.
> 
> gradientDisk::usage = 
>   "gradientDisk[{xcenter, ycenter}, radius, color] will draw an \
> outlined disk with the color blended from White to full color across \
> the radius.";
> SyntaxInformation[
>    gradientDisk] = {"ArgumentsPattern" -> {{_, _}, _, _}};
> gradientDisk[{xcenter_, ycenter_}, radius_, color_] :=
>  {RegionDraw[(x - xcenter)^2 + (y - ycenter)^2 < radius^2, {x, 
>     xcenter - radius, xcenter + radius}, {y, ycenter - radius, 
>     ycenter + radius},
>    ColorFunctionScaling -> False,
>    ColorFunction -> 
>     Function[{x, y}, 
>      Blend[{White, color}, 
>       Rescale[Sqrt[(x - xcenter)^2 + (y - ycenter)^2], {0, radius}]]]],
>   AbsoluteThickness[1],
>   Circle[{xcenter, ycenter}, radius]} 
> 
> Adapt it to the WRI form of Bubble data with a particular color selection
> for the bubbles.
> 
> myBubble[{x_, y_, r_}] := 
>  gradientDisk[{x, y}, r, ColorData["SolarColors"][Rescale[r, {0, 2}]]]
> 
> Then draw the bubble chart.
> 
> data = Array[{RandomReal[{-10, 10}], RandomReal[{-10, 10}], 
>      RandomReal[{0.1, 2}]} &, 20];
> Draw2D[
>  {myBubble /@ data},
>  Frame -> True,
>  ImageMargins -> 5,
>  PlotRange -> 12
>  ] 
> 
> Also, since WRI must have defined a primitive for SquareWaveBubble, say, how
> could we obtain direct access to it? (I know how to program one but since
> WRI has done, and buried, the work how about getting it out?)
> 
> 
> David Park
> djmpark at comcast.net
> http://home.comcast.net/~djmpark/  
> 
> 
> 
> 
> 
> From: M.Roellig [mailto:markus.roellig at googlemail.com] 
> 
> On 13 Jul., 11:28, Murta <rodrigomur... at gmail.com> wrote:
> > Hello All
> >
> >    There is really no way to do a simple gradient fill inside a disk
> > in Mathematica?
> >    I'm working in a BubbleChart, and would like to make a graphics
> > disk using ChartElements, going to color x to transparent using
> > opacity.
> >    I get surprised to see that there is no way to work with gradient
> > fill inside primitives like Disk.. there is really this?
> >    If it's true, please, correct it in Mathematica 8!...
> 
> Hi,
> 
> I agree, GradientFill would be nice, as well as TextureFill or any filling
> with arbitrary patterns. Until then you can try to construct it by yourself:
> 
> GradientDisk[] :=
>  Graphics[Table[{Hue[r], Circle[{0, 0}, r]}, {r, 0, 1, 0.001}]] ;
> BubbleChart[RandomReal[1, {10, 3}], ChartElements -> {GradientDisk[]}]
> 
> or
> 
> BWGradientDisk[] :=
>  Graphics[Table[{GrayLevel[r], Circle[{0, 0}, r]}, {r, 0, 1,
>     0.001}]];
> BubbleChart[RandomReal[1, {10, 3}],
>  ChartElements -> {BWGradientDisk[]}]
> 
> This takes quite some time, since many Circles are drawn. If somebody knows
> how to rasterize a circly without getting square image borders, one
> could use the rasterized image as Element. Maybe exporting to gif
> with transparent white background works.
> 
> Of course, the same excercise also works with Rectangles etc..
> 
> 
> Cheers,
> 
> Markus
> 
> 
> 



  • Prev by Date: Re: Fast pricer for American options
  • Next by Date: Re: how to display the value of w after using do?
  • Previous by thread: Re: Primitive Disk Gradient Fills in Graphics
  • Next by thread: Re: Primitive Disk Gradient Fills in Graphics