1
$\begingroup$

Image source: https://i.stack.imgur.com/Wgftu.png

I have a data set that can be generated as follows:

x=RandomReal[{1,5},100];
y=RandomReal[{11,50},100];
z=RandomReal[{7,25},100];

For each of the (x,y,z) 3-tuple, I want to make a 2D scattered plot of x vs. y and put a plot legend of z values in color bar with the figure as shown in the example image above.


I have used

ListLogLogPlot[Table[{x[[i]],y[[i]],z[[i]]},{i,Length@data], PlotLegends-> Automatic]

but cannot get what I want. Earlier, I used ListContourPlot, it was quite easy there but now I want a scattered plot.

How can I do it?

$\endgroup$
6
  • 1
    $\begingroup$ ListPointPlot3D[Transpose@{x, y, z}, PlotLegends -> Automatic] $\endgroup$
    – cvgmt
    Jun 19 at 11:34
  • $\begingroup$ I don't want a 3D plot. $\endgroup$
    – Pritam
    Jun 19 at 11:49
  • $\begingroup$ ListDensityPlot[Transpose[{x, y, z}], PlotLegends -> Automatic] $\endgroup$
    – Syed
    Jun 19 at 12:00
  • $\begingroup$ I have modified the question. I want something like that. $\endgroup$
    – Pritam
    Jun 19 at 12:06
  • $\begingroup$ BubbleChart[Partition[Transpose@{x, y, z}, 1], ChartLegends -> Automatic]? $\endgroup$
    – cvgmt
    Jun 19 at 12:23

2 Answers 2

1
$\begingroup$

Using Graphics

Clear["Global`*"]

SeedRandom[1];
x = RandomReal[{1, 5}, 100];
y = RandomReal[{11, 50}, 100];
z = RandomReal[{7, 25}, 100];

zRng = MinMax[z];

Legended[
 Graphics[{AbsolutePointSize[6],
   {ColorData[{"SolarColors", "Reverse"}][Rescale[#[[3]], zRng]],
      Tooltip[Point@Most@#, NumberForm[#, {5, 1}]]} & /@
    Transpose[{x, y, z}]},
  Frame -> True,
  FrameLabel -> (Style[#, 14] & /@ {HoldForm[x], HoldForm[y]}),
  AspectRatio -> 1],
 BarLegend[
  {{"SolarColors", "Reverse"}, zRng},
  LegendLabel -> Style[HoldForm[z], 14]]]

enter image description here

$\endgroup$
1
  • $\begingroup$ This is exactly what I wanted. Thank you Bob. $\endgroup$
    – Pritam
    Jun 22 at 10:12
3
$\begingroup$
SeedRandom[1];
x = RandomReal[{1, 5}, 100]; y = RandomReal[{11, 50}, 100]; z = 
 RandomReal[{7, 25}, 100];

BubbleChart[Transpose[{x, y, z}], 
 ColorFunction -> (ColorData[{"SolarColors", "Reverse"}][#3] &)
 , ChartLegends -> 
  Placed[BarLegend[{ColorData[{"SolarColors", "Reverse"}], 
     MinMax[z]}], After]
 ]

enter image description here

$\endgroup$
1
  • $\begingroup$ Add: , BubbleSizes -> {0.04, 0.04} if you require all bubbles to be the same size; although, this would instantly defeat the purpose of the bubble chart. $\endgroup$
    – Syed
    Jun 19 at 21:03

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.