Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is the CellCenter datapoints and associated Normals data:

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.

share|improve this question
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. – Michael E2 Mar 13 '13 at 23:46
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. – l3win Mar 14 '13 at 0:04
Can I perhaps zoom in on some of the data points, shrink the normals alot and see how they are distrubuted? – l3win Mar 14 '13 at 2:46
up vote 1 down vote accepted

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});
  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 &];
    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}
share|improve this answer
Thanks Michael! This works. But is there any way I can reduce the size of all this. Mathematica crashes when running the manipulate module. – l3win Mar 14 '13 at 19:24
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. – Michael E2 Mar 14 '13 at 19:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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