Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6046

Re: List plot with random size for each point

From DrMajorBob <btreat1@austin.rr.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: List plot with random size for each point
Date 2011-10-30 09:34 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j8j5n3$fa3$1@smc.vnet.net> (permalink)
References <201110280936.FAA20855@smc.vnet.net>

Show all headers | View raw


Actually, my second solution DOES work for 4 points. Three points is the  
case that fails.

I suspect it's more efficient to use Replace with a level spec, rather  
than restricting the pattern:

numberOfPoints = 3;
particle =
   Table[{n,
     RandomInteger[{15, 25}], {RandomInteger[{0, 200}],
      RandomInteger[{0, 200}]}}, {n, numberOfPoints}];
Graphics[Replace[
   particle, {label_, size_, pt_} :> {AbsolutePointSize@size, Point@pt,
      White, Text[label, pt]}, {1}], Frame -> True,
  PlotRange -> {{-12, 213}, {-12, 213}}, ImageSize -> 500]

Bobby

On Sat, 29 Oct 2011 22:59:09 -0500, Bob Hanlon <hanlonr357@gmail.com>  
wrote:

> A good approach; however, as written they will fail for numberOfPoints   > 4
>
> Recommend that you qualify one or more patterns to being numeric, e.g.,
>
> Graphics[particle /. {label_?NumericQ, size_, x_,
>     y_} :> {AbsolutePointSize@size, Point@{x, y}, White,
>     Text[label, {x, y}]}, Frame -> True,
>  PlotRange -> {{-12, 213}, {-12, 213}}, ImageSize -> 500]
>
>
> Bob Hanlon
>
>
> On Sat, Oct 29, 2011 at 1:55 PM, DrMajorBob <btreat1@austin.rr.com>  
> wrote:
>> Or equivalently,
>>
>> numberOfPoints = 20;
>> particle =
>>  Table[{n, RandomInteger[{15, 25}], RandomInteger[{0, 200}],
>>    RandomInteger[{0, 200}]}, {n, numberOfPoints}];
>> Graphics[particle /. {label_, size_, x_,
>>    y_} :> {AbsolutePointSize@size, Point@{x, y}, White,
>>    Text[label, {x, y}]}, Frame -> True,
>>  PlotRange -> {{-12, 213}, {-12, 213}}, ImageSize -> 500]
>>
>> or
>>
>> numberOfPoints = 20;
>> particle =
>>  Table[{n,
>>    RandomInteger[{15, 25}], {RandomInteger[{0, 200}],
>>     RandomInteger[{0, 200}]}}, {n, numberOfPoints}];
>> Graphics[particle /. {label_, size_,
>>    pt_List} :> {AbsolutePointSize@size, Point@pt, White,
>>    Text[label, pt]}, Frame -> True,
>>  PlotRange -> {{-12, 213}, {-12, 213}}, ImageSize -> 500]
>>
>> I find those more transparent.
>>
>> Bobby
>>
>> On Sat, 29 Oct 2011 06:13:56 -0500, Bob Hanlon <hanlonr357@gmail.com>  
>> wrote:
>>
>>> numberOfPoints = 20;
>>>
>>> particle = Table[
>>>   {n, RandomInteger[{15, 25}],
>>>    RandomInteger[{0, 200}], RandomInteger[{0, 200}]},
>>>   {n, numberOfPoints}];
>>>
>>> Graphics[
>>>  {AbsolutePointSize[#[[2]]], Point[#[[{3, 4}]]],
>>>    White, Text[#[[1]], #[[{3, 4}]]]} & /@
>>>  particle,
>>>  Frame -> True,
>>>  PlotRange -> {{-12, 213}, {-12, 213}},
>>>  ImageSize -> 500]
>>>
>>>
>>> Bob Hanlon
>>>
>>>
>>> On Fri, Oct 28, 2011 at 5:36 AM, Rudresh <rudresh@email.unc.edu> wrote:
>>>>
>>>> I want to plot an array of numbers on a 2d plot, however each point  
>>>> has a
>>>> random number associated with it which should be its size on the  
>>>> plot. Can
>>>> this be done in mathematica and if so how. My code as of now is:
>>>>
>>>> =========================
>>>>
>>>> particle = Array[f, {200, 4}];
>>>> position = Array[g, {200, 2}];
>>>> n = 1;
>>>> While  [n < 201,
>>>>       particle[[n, 1]] = n;
>>>>       particle[[n, 2]] = RandomInteger[{15, 25}];
>>>>       particle[[n, 3]] = RandomInteger[{0, 200}];
>>>>       particle[[n, 4]] = RandomInteger[{0, 200}];
>>>>
>>>>  position[[n, 1]] = particle[[n, 3]];
>>>>  position[[n, 2]] = particle[[n, 4]];
>>>>  n++
>>>>  ];
>>>>
>>>> ListPlot[position, PlotStyle -> PointSize[0.01],
>>>>  PlotRange -> {{0, 200}, {0, 200}}]
>>>>
>>>> =========================
>>>>
>>>> I want particle[[n,2]] to be the size of position[[n,1],[n,2]]
>>>>
>>>
>>
>>
>> --
>> DrMajorBob@yahoo.com
>>


-- 
DrMajorBob@yahoo.com

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: List plot with random size for each point DrMajorBob <btreat1@austin.rr.com> - 2011-10-30 09:34 +0000

csiph-web