1
$\begingroup$

This is the CellCenter datapoints and associated Normals data: http://wikisend.com/download/458974/CellCenters-and-Normals.dat

The dat file contains data points for x,y coordinates and x,y coordinates of four normal vectors associated with these coordinates. I don't know if I have done this right, so I am trying to plot up my datapoints and the four normals associated with each datapoint. I should be able to plot the datapoints and the four normals emerging from the datapoints ( with the tail of each normal ending at appropriate datapoint)

I don´t really know how to scale my vector plots so the arrows will fit to the meshgrid and cell center points.

CellDataNormals = 
Import["C:\\Users...\\CellCenters-and-Normals.dat", "Table", 
"IgnoreEmptyLines" -> True];

CellCenterx = CellDataNormals[[All, 1]];
CellCentery = CellDataNormals[[All, 2]];
CellCenter = Transpose[{CellCenterx, CellCentery}];

NormalEastx = CellDataNormals[[All, 3]];
NormalEasty = CellDataNormals[[All, 4]];
NormalEast = Transpose[{NormalEastx, NormalEasty}]; 

NormalNorthx = CellDataNormals[[All, 5]];
NormalNorthy = CellDataNormals[[All, 6]];
NormalNorth = Transpose[{NormalNorthx, NormalNorthy}];

NormalWestx = CellDataNormals[[All, 7]];
NormalWesty = CellDataNormals[[All, 8]];
NormalWest = Transpose[{NormalWestx, NormalWesty}];

NormalSouthx = CellDataNormals[[All, 9]];
NormalSouthy = CellDataNormals[[All, 10]];
NormalSouth = Transpose[{NormalSouthx, NormalSouthy}]; 

CenterPoints = 
ListPlot[CellCenter, PlotRange -> {{-11, 11}, {-11, 11}}];

NEast = ListVectorPlot[Transpose[{CellCenter, NormalEast}]];

NNorth = ListVectorPlot[Transpose[{CellCenter, NormalNorth}]];

NWest = ListVectorPlot[Transpose[{CellCenter, NormalWest}]];

NSouth = ListVectorPlot[Transpose[{CellCenter, NormalSouth}]];

Show[CenterPoints, NEast, NNorth, NWest, NSouth]

enter image description here

Is there a way I can scale all this and plot it on the same graph so that it looks prettier :) ? I don't really know how to scale the size of my datapoints and vector arrows.

$\endgroup$
3
  • $\begingroup$ Have you looked at things like VectorStyle -> {Red, Arrowheads[Tiny]} in the manual page for ListVectorPlot? Right now I don't know how to get four arrows at each point, for so many points, to look good. $\endgroup$
    – Michael E2
    Commented Mar 13, 2013 at 23:46
  • $\begingroup$ Thank you for the comment Michael. Yes, I had looked at that. The Problem is also that ListVectorPlot only plots a few vectors, it doesn't plot all the vectors. $\endgroup$
    – l3win
    Commented Mar 14, 2013 at 0:04
  • $\begingroup$ Can I perhaps zoom in on some of the data points, shrink the normals alot and see how they are distrubuted? $\endgroup$
    – l3win
    Commented Mar 14, 2013 at 2:46

1 Answer 1

1
$\begingroup$

Perhaps the following will give you some ideas about how you could proceed.

Here's some random data that seems to be structured like yours, although the values may be far from realistic (sorry for not using yours):

data = With[{n = 25}, 
   MapThread[Join, {RandomReal[{-10, 10}, {n, 2}], RandomReal[{-1, 1}, {n, 8}]}]];

This partitions each line of data into pairs (center, normal, normal, normal, normal):

centersNormals = Partition[#, 2] & /@ data;

You might get more control over the individual points with Graphics:

normalArrows[{ctr_List, normals__List}] := (* turns a line of data into four arrows *)
  Arrow /@ ({ctr, ctr + #} & /@ {normals});
Graphics[{
  Arrowheads[Small],
  Riffle[Hue /@ Range[0., 0.99, 1/4], (* shuffles colors between the groups of normals *)
   Transpose[normalArrows /@ centersNormals]], (* groups all East normals, North normals etc. *)
  Point[First /@ centersNormals] (* plots call center locations *)
  }, Axes -> True]

Centers and normals plot

You can use Select to choose a range of the data and zoom in on an area:

Manipulate[Module[{x0, y0, centersNormals},
  {x0, y0} = location; 
  centersNormals = Partition[#, 2] & /@
    Select[data, x0 - radius < #[[1]] < x0 + radius && y0 - radius < #[[2]] < y0 + radius &];
  Graphics[{
    Arrowheads[Small], ColorData[1][1],
    Riffle[Hue /@ Range[0., 0.99, 1/4], 
     Transpose[normalArrows /@ centersNormals]],
    Point[First /@ centersNormals]
    }, Frame -> True, 
   PlotRange -> {{x0 - radius, x0 + radius}, {y0 - radius, y0 + radius}}, PlotRangePadding -> 1]
  ],
 {{location, {0, 0}}, {-10, -10}, {10, 10}}, {{radius, 10}, 1, 10}
 ]
$\endgroup$
2
  • $\begingroup$ Thanks Michael! This works. But is there any way I can reduce the size of all this. Mathematica crashes when running the manipulate module. $\endgroup$
    – l3win
    Commented Mar 14, 2013 at 19:24
  • $\begingroup$ I take it that it's because you're running out of memory? Perhaps if you start with a small radius (try 1 instead of 10). I don't see where the code is a memory hog, except that dataZoom and centersNormals duplicate each other and part of data. I'll edit it. It's quick, but it might only help a little. $\endgroup$
    – Michael E2
    Commented Mar 14, 2013 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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