From: M.Roellig on
On 13 Jul., 11:28, Murta <rodrigomur...(a)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

From: Murta on
On 14 jul, 06:36, "David Park" <djmp...(a)comcast.net> wrote:
> Here is a solution using Presentations. You should also be able to do this
> using RegionPlot, Show and some graphics level jumping.
>
> Needs["Presentations`Master`"]
>
> gradientDisk::usage =
> "gradientDisk[{xcenter, ycenter}, radius, color] will draw an \
> outlined colored disk with the color blended from White to full color \
> across the the horizontal dimension.";
> 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[x, {xcenter - radius, xcenter + radius}]]]],
> AbsoluteThickness[1],
> Circle[{xcenter, ycenter}, radius]}
>
> Draw2D[
> {gradientDisk[{0, 0}, 1, Red],
> gradientDisk[{2, 2}, 1/2, Green],
> gradientDisk[{-2, 1}, .45, Blue]},
> Frame -> True,
> PlotRange -> 4
> ]
>
> David Park
> djmp...(a)comcast.nethttp://home.comcast.net/~djmpark/
>
> From: Murta [mailto:rodrigomur...(a)gmail.com]
>
> 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!...

Thanks for All the reply.
I will construct it in the ways suggested. But I hope Mathematica 8
came better in this itens!
tks
Rodrigo Murta

From: David Park on
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(a)comcast.net
http://home.comcast.net/~djmpark/





From: M.Roellig [mailto:markus.roellig(a)googlemail.com]

On 13 Jul., 11:28, Murta <rodrigomur...(a)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



From: David Park on
Many thanks for that Patrick.

I don't think one has to Unprotect ChartElementData. At least, I had no
problem. Here is an example of getting out these primitives and using them
in your own custom plot.

The possible types of primitives for BubbleChart:

ChartElementData["BubbleChart"]

{"Bubble", "FadingBubble", "GradientBubble", "MarkerBubble", \
"NoiseBubble", "OscillatingBubble", "PolyhedronBubble", \
"SphereBubble", "SquareWaveBubble", "TriangleWaveBubble"}

Examine one of these with Manipulate.

ChartElementData["SquareWaveBubble", "Manipulate"]

Insert a specific case to see the form of the function.

ChartElementDataFunction["SquareWaveBubble", "AngularFrequency" -> 20,
"RadialAmplitude" -> 0.1`]

Now design a custom primitive. This one specifies the location, size and
color for a SquareWaveBubble. The RadialAmplitude varies with the size.
(Look up ChartElementFunction for more details.)

myBubble[x_, y_, size_, color_] := {color,
ChartElementDataFunction["SquareWaveBubble",
"AngularFrequency" -> 20,
"RadialAmplitude" :> Rescale[size, {.2, 3}, {1, 0}]][{{x - size/2,
x + size/2}, {y - size/2, y + size/2}}, {x, y}]}

Here is some data and a plot done outside of BubbleChart.

data = Table[{RandomReal[{-10, 10}], RandomReal[{-10, 10}],
s = RandomReal[{.2, 3}],
ColorData["DarkRainbow"][Rescale[s, {.2, 3}]]}, {i, 15}];
Graphics[
{myBubble @@@ data},
AspectRatio -> Automatic,
Frame -> True,
PlotRange -> 13]

However, this does depend on having an Automatic AspectRatio.

David Park
djmpark(a)comcast.net
http://home.comcast.net/~djmpark/











From: Patrick Scheibe [mailto:pscheibe(a)trm.uni-leipzig.de]

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:
>
> 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(a)comcast.net
> http://home.comcast.net/~djmpark/
>


From: Patrick Scheibe on
Hi again,

> I don't think one has to Unprotect ChartElementData. At least, I had no
> problem. Here is an example of getting out these primitives and using them
> in your own custom plot.

what I meant was, that there is here (Linux 64, Mathematica 7.0.1) no direct
documentation of ChartElementData. Unprotecting (read protection) the
symbol and using ?? for looking at the definition was the way I found
out about the usage.
Of course you can use it without unprotecting the symbol.

Cheers
Patrick


> The possible types of primitives for BubbleChart:
>
> ChartElementData["BubbleChart"]
>
> {"Bubble", "FadingBubble", "GradientBubble", "MarkerBubble", \
> "NoiseBubble", "OscillatingBubble", "PolyhedronBubble", \
> "SphereBubble", "SquareWaveBubble", "TriangleWaveBubble"}
>
> Examine one of these with Manipulate.
>
> ChartElementData["SquareWaveBubble", "Manipulate"]
>
> Insert a specific case to see the form of the function.
>
> ChartElementDataFunction["SquareWaveBubble", "AngularFrequency" -> 20,
> "RadialAmplitude" -> 0.1`]
>
> Now design a custom primitive. This one specifies the location, size and
> color for a SquareWaveBubble. The RadialAmplitude varies with the size.
> (Look up ChartElementFunction for more details.)
>
> myBubble[x_, y_, size_, color_] := {color,
> ChartElementDataFunction["SquareWaveBubble",
> "AngularFrequency" -> 20,
> "RadialAmplitude" :> Rescale[size, {.2, 3}, {1, 0}]][{{x - size/2,
> x + size/2}, {y - size/2, y + size/2}}, {x, y}]}
>
> Here is some data and a plot done outside of BubbleChart.
>
> data = Table[{RandomReal[{-10, 10}], RandomReal[{-10, 10}],
> s = RandomReal[{.2, 3}],
> ColorData["DarkRainbow"][Rescale[s, {.2, 3}]]}, {i, 15}];
> Graphics[
> {myBubble @@@ data},
> AspectRatio -> Automatic,
> Frame -> True,
> PlotRange -> 13]
>
> However, this does depend on having an Automatic AspectRatio.
>
> David Park
> djmpark(a)comcast.net
> http://home.comcast.net/~djmpark/
>
>
>
>
>
>
>
>
>
>
>
> From: Patrick Scheibe [mailto:pscheibe(a)trm.uni-leipzig.de]
>
> 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:
> >
> > 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(a)comcast.net
> > http://home.comcast.net/~djmpark/
> >
>