1
$\begingroup$

I want to plot a list of the form whose elements are of the form

{value, {x -> value_x, y -> value_y}}

The list generated by FindMaximum applied on function with different initial positions. This means, that I have to transform the upper list to

{value_x, value_y, value}

Any ideas?

$\endgroup$
0

3 Answers 3

3
$\begingroup$
ListPointPlot3D[Join[#[[2,All,2]],{#[[1]]}]&/@yourList]

... or use ListPlot3D rather than the point plot. The command inside the ListPointPlot3D will extend to more dimensions and also works when your list contains say...

{{43, {u->6,v->2,w->5}} <<more items>> }

$\endgroup$
2
$\begingroup$
s = {value, {x -> value_x, y -> value_y}}

{x /. s[[2]], y /. s[[2]], s[[1]]}
$\endgroup$
2
  • 1
    $\begingroup$ C'mon Jim, you have been a member for 8 months. You can at least format your code properly. $\endgroup$
    – Sektor
    May 22, 2015 at 17:50
  • 1
    $\begingroup$ @Sektor. Guilty as charged. I will be more diligent in the future. $\endgroup$
    – JimB
    May 22, 2015 at 18:22
2
$\begingroup$
♭♭ = ## & @@@ {#2 & @@@ #2, #} & @@ # &;

Example:

lst ={{35.3919, {x -> 3.17532, y -> 0.826616}}, 
      {22.7658, {x -> 2.74215, y -> 1.86474}}, 
      {47.6532, {x -> 2.59448, y -> 5.939}}, 
      {51.3295, {x -> 2.25842, y -> 5.10077}}, 
      {26.2436, {x -> 1.23835, y -> 2.10218}},
      {36.0848, {x -> 1.85455, y -> 4.04917}}, 
      {52.9884, {x -> 2.7727,  y -> 4.73459}}, 
      {18.9687, {x -> 4.42552, y -> 3.75128}}}

lst2 = ♭♭ /@ lst

{{3.17532, 0.826616, 35.3919},
{2.74215, 1.86474, 22.7658},
{2.59448, 5.939, 47.6532},
{2.25842, 5.10077, 51.3295},
{1.23835, 2.10218, 26.2436},
{1.85455, 4.04917, 36.0848},
{2.7727, 4.73459, 52.9884},
{4.42552, 3.75128, 18.9687}}

 BubbleChart3D[{##, 1} & @@@ lst2, BubbleSizes -> {.05, .05}, ChartStyle -> 1]

Mathematica graphics

ListPointPlot3D[List /@ lst2, PlotStyle -> ColorData[1, "ColorList"], 
 BaseStyle -> PointSize[.05], BoxRatios -> 1]

Mathematica graphics

$\endgroup$

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