4
$\begingroup$

I would like to draw a bubblechart with loglog scale

I have a data set such as:

review = {{1500000000, 0.066666667, 0.001333, 0.05, 0.001333333, 0.1, 
0.075, "CEBAF Opr"}, {1500000000, 2.666666667, 0.05333, 0.05, 
0.053333333, 4, 0.075, "CEBAF R&D"}, {120, 12000, 6, 2, 6, 
0.00144, 0.00000024, "SLC"}, {10000, 7500, 4.688, 2, 3.75, 0.0375,
 0.00001, "EIC R&D"}, {8, 7500, 1.6, 4.375, 4.6875, 0.00006, 
1.28 10^-8, "EIC Specs"}, {2500000, 0.02, 0.0000125, 1.6, 
0.0000125, 0.00005, 0.004, "MAMI"}, {10, 250000, 0.01, 25000, 
0.01, 0.0025, 0.00025, "MIT-BATES"}, {50, 100000, 0.1, 1000, 0.1, 
0.005, 0.00005, "Bonn-ELSA"}};

The first element is x, the second element is y and bubble size is the third element, I tried

    BubbleChart[
 Table[{review[[n, 1]], review[[n, 2]], review[[n, 3]]}, {n, 
   Length[review]}], Frame -> True, 
 FrameLabel -> {"Frequency[Hz]", "Bunch Charge [pC]"}]

I cannot find log in the bubblechart, all the bubbles are overlapped

Any suggestions to make a better bubblechart in Mathematica?

Appreciate @kglr's answer, I put Scalingfunctions on, however the ChartLabels does not work...

    Show[Plot[{10^13/fre, 10^11/fre, 10^9/fre, 10^7/fre, 10^5/fre, 10^3/
   fre, 10/fre, 0.1/fre}, {fre, 1, 10^10}, GridLines -> Automatic, 
  PlotStyle -> {{Gray, Dashed, Thick}}, Frame -> True, 
  FrameLabel -> {"Frequency [Hz]", "Bunch Charge [pC]"}, 
  ScalingFunctions -> {"Log", "Log"}, 
  PlotRange -> {{1, 10^10}, {0.01, 10^6}}, PlotTheme -> "Scientific", 
  AspectRatio -> 0.9], 
 BubbleChart[review[[All, ;; 3]], 
  GridLinesStyle -> Directive[Gray, Dashed], 
  ChartLabels -> Placed[review[[All, 8]], Center], 
  LabelingSize -> Full, ChartStyle -> 45, 
  ScalingFunctions -> {"Log", "Log"}, BubbleSizes -> {0.04, 0.17}]
 ]

enter image description here

$\endgroup$
1
  • $\begingroup$ Evaluate Options[BubbleChart] $\endgroup$
    – Bob Hanlon
    Oct 5, 2021 at 4:03

1 Answer 1

5
$\begingroup$

Update: When we use ScalingFunctions -> {"Log","Log"} with the option ChartLabels -> ... the labels do not show:

labels = CharacterRange["A", "Z"][[;; Length@review]];

BubbleChart[review[[All, ;; 3]], Frame -> True, 
 FrameLabel -> {"Frequency[Hz]", "Bunch Charge [pC]"}, 
 ChartLabels -> labels]

enter image description here

BubbleChart[review[[All, ;; 3]], Frame -> True, 
 FrameLabel -> {"Frequency[Hz]", "Bunch Charge [pC]"}, 
 ScalingFunctions -> {"Log", "Log"}, ChartLabels -> labels]

enter image description here

A work-around: Define an association linking labels to the Log of xy coordinates:

labelsToXY = AssociationThread[labels, Log @ review[[All, ;; 2]]];

We can use labelsToXY in several ways:

  1. Add the labels using Epilog:

BubbleChart[review[[All, ;; 3]], Frame -> True, 
 FrameLabel -> {"Frequency[Hz]", "Bunch Charge [pC]"}, 
 ScalingFunctions -> {"Log", "Log"}, 
 Epilog -> (Text[#, labelsToXY @ #] & /@ labels)]

enter image description here

  1. Post-process BubbleChart output to correct the positions of labels:

ReplaceAll[Text[t_, a_, b___] :> Text[t, labelsToXY @ t[[1]], b]] @
 BubbleChart[review[[All, ;; 3]], Frame -> True, 
  FrameLabel -> {"Frequency[Hz]", "Bunch Charge [pC]"}, 
  ScalingFunctions -> {"Log", "Log"}, ChartLabels -> labels]

same picture

  1. Use the option DisplayFunction to do the post-processing inside BubbleChart:

BubbleChart[review[[All, ;; 3]], Frame -> True, 
 FrameLabel -> {"Frequency[Hz]", "Bunch Charge [pC]"}, 
 ScalingFunctions -> {"Log", "Log"}, ChartLabels -> labels, 
 DisplayFunction -> 
   ReplaceAll[Text[t_, a_, b___] :> Text[t, labelsToXY @ t[[1]], b]]]

same picture

Original answer:

Add the option ScalingFunctions -> {"Log", "Log"}:

BubbleChart[review[[All, ;;3]],
 Frame -> True, 
 FrameLabel -> {"Frequency[Hz]", "Bunch Charge [pC]"}, 
 ScalingFunctions -> {"Log", "Log"}]

enter image description here

$\endgroup$
4
  • $\begingroup$ Thank you very much. $\endgroup$
    – rfeynman
    Oct 6, 2021 at 14:08
  • $\begingroup$ Looks once add Scalingfunctions on, the ChartLabels does not work... Any ideas? $\endgroup$
    – rfeynman
    Oct 6, 2021 at 14:31
  • $\begingroup$ @rfeynman, it looks like a bug. Please add your comment to your post so that it is more visible. I will post a work-around to get the labels right. $\endgroup$
    – kglr
    Oct 6, 2021 at 15:50
  • $\begingroup$ ,Thank you, I updated the question. $\endgroup$
    – rfeynman
    Oct 7, 2021 at 1:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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