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
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
djm...@comcast.net
http://home.comcast.net/~djmpark/
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
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?)
From: M.Roellig [mailto:markus....@googlemail.com]
On 13 Jul., 11:28, Murta <rodrigomur...@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 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.
From: Patrick Scheibe [mailto:psch...@trm.uni-leipzig.de]
Hi all,
just clear the protection attributes of ChartElementData and find out
that
ChartElementData["GradientBubble", "Manipulate"]
should help.
Cheers
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.
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
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
> djm...@comcast.net
> http://home.comcast.net/~djmpark/
>
>
>
>
>
On Jul 16, 6:19 am, Patrick Scheibe <psche...@trm.uni-leipzig.de>
wrote:
> ChartElementData["SquareWaveBubble", "Manipulate"]
gives a very interesting result but as far as I can find both ChartElementData
& the Manipulate option are undocumented.
Is this available with documentation in a Developer Version of Mathematica by chance?
Cheers .... Syd
Syd Geraghty B.Sc, M.Sc.
Mathematica 7.0.1.0 for Mac OS X x86 (64 - bit) (12th September 2009)
MacOS X V 10.6.1 Snow Leopard
MacBook Pro 2.33 GHz Intel Core 2 Duo 2GB RAM