Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: 2D plots of data points

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109704] Re: 2D plots of data points
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Wed, 12 May 2010 07:35:46 -0400 (EDT)

Not sure that I understand what you want. Here's a guess.

data = {{1, 2, 3}, {4, 5, 6} , {7, 8, 9}};

pts =
 {#, Position[Transpose[data], #][[1]]} & /@
   Flatten[data] /. {x_, y_Integer} -> {x - 1, 1 - y}

{{1, {0, 0}}, {2, {1, 0}}, {3, {2, 
   0}}, {4, {0, -1}}, {5, {1, -1}}, {6, {2, -1}}, 
   {7, {0, -2}}, {8, {1, -2}}, {9, {2, -2}}}

Alternatively,

pts =
 {#, (Position[Transpose[data], #][[1]] - 1) {1, -1}} & /@
  Flatten[data]

{{1, {0, 0}}, {2, {1, 0}}, {3, {2, 
   0}}, {4, {0, -1}}, {5, {1, -1}}, {6, {2, -1}}, 
   {7, {0, -2}}, {8, {1, -2}}, {9, {2, -2}}}

Show[
 Graphics[
  {Circle[#[[2]], .5], Text[Style[#[[1]], 24], #[[2]]]} & /@ pts],
 Frame -> True]

Show[
 Graphics[
  {Blue, Disk[#[[2]], .5], Text[Style[#[[1]], White, 24], #[[2]]]} & /@ pts],
 Frame -> True]


Bob Hanlon

---- Niles <niels.martinsen at gmail.com> wrote: 

=============
Greetings, friends

I have the data-points {1,2,3}, {4,5,6} and {7,8,9} and I wish to plot
them in a 2D-plot (x,y) ranging from x:0..2 and y:-2..0. The
coordinates of the points should be

1: (0,0)
2: (1,0)
3: (2,0)
4: (0,-1)
5: (1,-1)
6: (2,-1)
7: (0,-2)
8: (1,-2)
9: (2,-2)

Is there a smart way of doing this? is it furthermore possible to make
the data-points larger, i.e. so there is no white-space between the
points? Any hints/help will be greatly appreciated.

Sincerely, Niles.



  • Prev by Date: Why do these not work?
  • Next by Date: Different answer when running cell second time?
  • Previous by thread: Re: 2D plots of data points
  • Next by thread: implicit function