1
$\begingroup$

In a BubbleChart, how can I influence the elements plotted depending on a value in the tuple plotted?

I want to create a BubbleChart from the following data:

 lines = {{1, 10, 2}, {2, 15, 1}, {3, 27, 4}, {4, 35, 2}}

but instead of the bubbles, I want to draw a line as long as z.

$\endgroup$
  • $\begingroup$ had to reward myself by smarty-pantsing the answer right away, as it took some reading the documentation. Sadly, the predictive interface did not do my homework for me... $\endgroup$ – Florenz Kley Nov 13 '13 at 22:45
3
$\begingroup$

ChartElementFunction to the rescue! It not only has a couple of builtin functions to change the plotted elements

ChartElementData["BubbleChart"]

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

but it's also possible to define a custom function that will be fed by BubbleChart. For each plotted tuple, it receives [region, values, metadata] and can be used to plot lines like

lines = {{1, 10, 2}, {2, 15, 1}, {3, 27, 4}, {4, 35, 2}}
doline[___, {x_, y_, z_}, ___] :=
 Line[{{x, y}, {x + z, y}}]
BubbleChart[lines, ChartElementFunction -> doline]

enter image description here

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.