2
$\begingroup$

I have following data

data={{{"MYCBP2", 7, 1.31161, 7}, {"F5", 6, 1.65189, 6}, {"IRF2BPL", 6, 
   1.65189, 6}, {"DMXL1", 6, 1.65189, 6}, {"MROH2B", 6, 1.65189, 
   6}, {"MACF1", 6, 1.65189, 6}, {"IRS4", 1, 1.31161, 1}, {"HECTD1", 
   6, 1.65189, 6}, {"KIAA0232", 6, 1.65189, 6}, {"CUBN", 8, 1.63422, 
   8}, {"PURB", 6, 1.65189, 6}, {"FHOD1", 0, 1.65189, 0}}, {{"CEP350",
    7, 2.01659, 7}, {"VPS13C", 7, 2.01659, 7}, {"SPEN", 6, 2.01795, 
   6}, {"DNAH3", 7, 2.01659, 7}, {"ERCC2", 9, 2.78759, 9}, {"ANK2", 9,
    2.78759, 9}, {"HERC1", 8, 2.39479, 8}, {"KRT4", 9, 2.78759, 
   9}, {"TYRO3", 1, 2.33592, 1}, {"KMT2C", 19, 6.72092, 19}, {"AKAP9",
    9, 2.78759, 9}}};
BubbleChart[data[[All, All, 2 ;; 4]]]

enter image description here

How can I apply Calloutfuntion to data? Note that some data are overlap so I want multiple callout to same bubble if possible. Bubble labels are first entry of data. Any suggestion?

$\endgroup$
2
  • $\begingroup$ Did you see the Callout examples under Scope -> Labeling and legending in the BubbleChart documentation? $\endgroup$
    – C. E.
    Commented Feb 14, 2021 at 2:27
  • $\begingroup$ Yes, I did. For some reason I couldn't figure it out. Same data point different label cause some problem I guess. $\endgroup$ Commented Feb 14, 2021 at 3:37

2 Answers 2

4
$\begingroup$

After playing with your data, I saw some strange behaviors from Mathematica 12.2.

data = {{{"MYCBP2", 7, 1.31161, 7}, {"F5", 6, 1.65189, 6}, {"IRF2BPL",
      6, 1.65189, 6}, {"DMXL1", 6, 1.65189, 6}, {"MROH2B", 6, 1.65189,
      6}, {"MACF1", 6, 1.65189, 6}, {"IRS4", 1, 1.31161, 
     1}, {"HECTD1", 6, 1.65189, 6}, {"KIAA0232", 6, 1.65189, 
     6}, {"CUBN", 8, 1.63422, 8}, {"PURB", 6, 1.65189, 6}, {"FHOD1", 
     0, 1.65189, 0}}, {{"CEP350", 7, 2.01659, 7}, {"VPS13C", 7, 
     2.01659, 7}, {"SPEN", 6, 2.01795, 6}, {"DNAH3", 7, 2.01659, 
     7}, {"ERCC2", 9, 2.78759, 9}, {"ANK2", 9, 2.78759, 9}, {"HERC1", 
     8, 2.39479, 8}, {"KRT4", 9, 2.78759, 9}, {"TYRO3", 1, 2.33592, 
     1}, {"KMT2C", 19, 6.72092, 19}, {"AKAP9", 9, 2.78759, 9}}};

I use Map to make Callout:

data2 = Map[Callout[#[[2 ;; 4]], #[[1]]] &, data, {2}]
(*Out: {{Callout[{7, 1.31161, 7}, "MYCBP2"], ... }, {Callout[{7, 2.01659, 7}, "CEP350"], ... }} *)

BubbleChart[data2, LabelingSize -> 30]

The chart will be plotted but with some errors and no callout enter image description here

Solution

But If you change the bubble size of {"FHOD1", 0, 1.65189, 0} which is zero to a non-zero value for example {"FHOD1", 0, 1.65189, 0.5}, errors will disappear and everything works as expected.

enter image description here

Problem

It looks like if you set bubble size to zero in any element of your data whether it's in Callout wrapper or not, Mathematica will not show any Callout. In Mathematica BubbleChart documentation in Details section mentioned:

The value z [bubble size] should be positive.

but it doesn't discuss Possible Issues of non-positive values. For example, we have two element with non-zero bubble size wrapped in Callout:

data3 = {Callout[{3, 2, 2}, "test"], Callout[{3, 3, 3}, "test"]};

BubbleChart[data3]

enter image description here

If I add an element with zero value in bubble size, whether it's wrapped in Callout or not, all the callouts will disappear:

data4 = Append[data3, {1.5, 2, 0}];

data5 = Append[data3, Callout[{1.5, 2, 0}, "test"]];

BubbleChart[data4]

BubbleChart[data5]

Results of BubbleChart for data4 and data5 are the same:

enter image description here

It's also interesting that in the example above no error raised but in your case, it did.

$\endgroup$
2
$\begingroup$

Your data is rather badly suited for display with BubbleChart. One problem is {"FHOD1", 0, 1.65189, 0} will never show up because its bubble will have zero radius and no area. Another problem is repeated labels make it impossible for BubbleChart to display callouts even when, as I do in this answer, they are combined into a single label for cases where the numberical data elements are identical. Because of the 2nd problem, my code will label the bubbles with tooltips. You can substitute Callout for Tooltip should want to see the problem callouts produces.

h[lbls_] := If[Length[lbls] == 1, lbls[[1]], StringJoin[Riffle[lbls, " : "]]]

gdat1 = GroupBy[data[[1]], #[[2 ;;]] & -> First, h];
bpdat1 = KeyValueMap[Tooltip[#1, #2] &, gdat1];
gdat2 = GroupBy[data[[2]], #[[2 ;;]] & -> First, h];
bpdat2 = KeyValueMap[Tooltip[#1, #2] &, gdat2];

Show[
  BubbleChart[bpdat2,
    PlotRange -> {{-1, 22}, {1.2, 7.4}}],
  BubbleChart[bpdat1,
    BubbleSizes -> {0.8, 2},
    ChartStyle -> ColorData[97][1],
    PlotRange -> {{-1, 22}, {1.2, 7.4}}]]

chart

$\endgroup$
2
  • $\begingroup$ Thanks for your answer. Unfortunately, Tooltip does not help in my case since figure will be published eventually. I'll consider replacing 0 to some small amount say $10^{-10}$ $\endgroup$ Commented Feb 14, 2021 at 20:12
  • $\begingroup$ @OkkesDulgerci. Replacing 0 with $10^-10$ wont make the bubble visible. $\endgroup$
    – m_goldberg
    Commented Feb 15, 2021 at 16:01

Your Answer

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

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