1
$\begingroup$

I have 6 sets of 4D points. Here is an example of one set :

{{30., 5., 111.925, 113.569}, {30., 7.5, 114.7, 158.286}, {30., 10., 115.625, 206.023},
 {30., 12.5, 115.625, 257.528}, {30., 15., 117.475, 294.663}, {30., 17.5, 119.325, 328.03},
 {30., 20., 121.175, 357.982}, {30., 22.5, 122.1, 393.646}, {30., 25., 122.1, 437.384},
 {30., 27.5, 122.1, 481.123}}

I want to plot the x,y coordinates of the points on the 2D plane and use the z coordinate to define the size of the symbol (bubble radius or area) and the last coordinate to define a color for that bubble. So the color will be different depending on the fourth coordinate. Any help would be appreciated !

I would like to have a 4D graphic like that : Bubble chart 4D

$\endgroup$
  • $\begingroup$ ...so the third component is a radius of the circle centered at the point made from the first two components? As for the fourth, you didn't specify how one should convert the fourth component to a color. $\endgroup$ – J. M. will be back soon Mar 9 '18 at 23:14
  • $\begingroup$ Yes you are right, sorry I was not enough specific ! For the color, the max fourth coordinate of all the points must correspond to the max of the chosen color scale (red by example) and the min coordinate to the minimum of the color scale (blue by example). $\endgroup$ – Adrien Mar 11 '18 at 9:56
  • $\begingroup$ Can you give an example set of points? $\endgroup$ – J. M. will be back soon Mar 11 '18 at 10:30
  • $\begingroup$ {{30., 5., 111.925, 113.569}, {30., 7.5, 114.7, 158.286}, {30., 10., 115.625, 206.023}, {30., 12.5, 115.625, 257.528}, {30., 15., 117.475, 294.663}, {30., 17.5, 119.325, 328.03}, {30., 20., 121.175, 357.982}, {30., 22.5, 122.1, 393.646}, {30., 25., 122.1, 437.384}, {30., 27.5, 122.1, 481.123}} $\endgroup$ – Adrien Mar 11 '18 at 15:23
  • $\begingroup$ Next time, just edit your question to include such additional data. $\endgroup$ – J. M. will be back soon Mar 11 '18 at 15:30
1
$\begingroup$

Just join all your data and use J.M's code.

data = {{30., 5., 111.925, 113.569}, {30., 7.5, 114.7, 158.286}, {30.,
     10., 115.625, 206.023}, {30., 12.5, 115.625, 257.528}, {30., 15.,
     117.475, 294.663}, {30., 17.5, 119.325, 328.03}, {30., 20., 
    121.175, 357.982}, {30., 22.5, 122.1, 393.646}, {30., 25., 122.1, 
    437.384}, {30., 27.5, 122.1, 481.123}};

data2 = Join[{data}, {data}, {data}];

data2[[2, All, 1]] += 30;
data2[[2, All, 2]] += 10;
data2[[2, All, 3]] += 15;
data2[[2, All, 4]] += 100;

data2[[3, All, 1]] += 60;
data2[[3, All, 2]] += 15;
data2[[3, All, 3]] += 25;
data2[[3, All, 4]] += 500;

data2 = Join @@ data2;



sc = {"ThermometerColors", MinMax[data2[[All, -1]]]};
cf = ColorData[sc];

Legended[Graphics[{cf[#4], Disk[{#, #2}, #3/30]} & @@@ data2, 
  Frame -> True, ImageSize -> 600, GridLines -> Automatic, 
  GridLinesStyle -> Directive[Gray, Dotted]], BarLegend[sc]]

enter image description here

Edit Here is a workaround. I am not sure this is what you want. You can use Ellipse instead of Disk and scale radius differently to overcome distortion.

p1 = ListPlot[{{-1, -1}}, Frame -> True, Axes -> False, 
   PlotRange -> {{0, 100}, {0, 50}}, ImageSize -> 500, 
   AspectRatio -> 1/3, GridLines -> Automatic, 
   GridLinesStyle -> Directive[Gray, Dotted]];
p2 = Graphics[{cf[#4], Ellipsoid[{#, #2}, {#3/30, #3/20}]} & @@@ 
    data2];
Legended[Show[{p1, p2}], BarLegend[sc]] 

enter image description here

$\endgroup$
  • $\begingroup$ That's what I dit and it works pretty well actually, thanks to JM and you. Just a detail (I am perfectionist...). Using this way you cannot use the option AspectRatio because it deforms the disks. As I said it is juste a detail but in the case where I use all my results the graphics is not looking good to be presented in a poster/publication. $\endgroup$ – Adrien Mar 12 '18 at 6:35
  • $\begingroup$ I tried something, see my edit. Be careful, in my first post, in Disk[center, radius] radius scaled by 1/30. It is up to you change or remove that scaling factor. $\endgroup$ – OkkesDulgerci Mar 12 '18 at 12:47
1
$\begingroup$

Using the given data:

data = {{30., 5., 111.925, 113.569}, {30., 7.5, 114.7, 158.286},
        {30., 10., 115.625, 206.023}, {30., 12.5, 115.625, 257.528},
        {30., 15., 117.475, 294.663}, {30., 17.5, 119.325, 328.03},
        {30., 20., 121.175, 357.982}, {30., 22.5, 122.1, 393.646},
        {30., 25., 122.1, 437.384}, {30., 27.5, 122.1, 481.123}};

sc = {"ThermometerColors", MinMax[data[[All, -1]]]}; cf = ColorData[sc];

Legended[Graphics[{cf[#4], Disk[{#, #2}, #3/100]} & @@@ data, Frame -> True],
         BarLegend[sc]]

diagram

$\endgroup$
  • $\begingroup$ Thanks it works but it looks weird when I import all my data and not just one sample : 6 columns of "bubbles" like the one you plotted (that's ok) but a very small graphics in comparison with the bar legend. I edit my question to add this info. $\endgroup$ – Adrien Mar 11 '18 at 20:54
3
$\begingroup$

Why not use BubbleChart with style wrappers?:

BubbleChart[
    Replace[
        {{3,4,3,5},{4,1,4,8}},
        {a_, b_, c_, d_} :> Style[{a, b, c}, Lighter[Green, d/10]],
        {1}
    ]
]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you for your proposal, it really helps ! I can almost get what I expect using the Blend function instead of Lighter but I would prefer to use one of the gradient color of the classical "schemes" if possible, as Rainbow, or TemperatureMap, because next I would like to add a colored bar legend to my graph. $\endgroup$ – Adrien Mar 11 '18 at 15:30

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.