Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have this code, and it generates the below ListStreamPlot. The second graph is the ListStreamPlot overlaid with the points comprising the ListStreamPlot (extracted after looking at // InputForm); unfortunately, the extracted points also include the border points. These "border points" are not of predictable coordinates, so there doesn't seem to be an easy way to remove them from the set. (I want this code to be as case-inspecific as possible, since I am analyzing many additional data sets.)

Is there a simple way -- perhaps in the original ListStreamPlot code -- to remove the "border points" from the points list?

v3 = ListStreamPlot[vectorsT, StreamStyle -> "Line", StreamPoints -> 
  {{xcorT[[midpoint + 4]], ycorT[[midpoint + 4]]}}]

points = v3[[1, 2, 1]];

xPoints = Transpose[points][[1]]; 
yPoints = Transpose[points][[2]];

pointsOnly = ListPlot[Transpose[Join[{xPoints}, {yPoints}]]] ;

graph 1:

graph 2:

Entire source code

(* Set directory to that of this notebook *)
SetDirectory[NotebookDirectory[]];

(* Import CSV'd data *)
dat = Import["test_data2b.txt", "CSV"];

(* Divide data *)
datAll = Flatten[Partition[dat[[1]], 7]];
datAllCpy = datAll;

(* Divide data into components *)
(* ID *)

ID = Flatten[Partition[datAll, 1, 7]];
datAll = RotateLeft[datAll];

(* Longitude *)
LONG = Flatten[Partition[datAll, 1, 7]];
datAll = RotateLeft[datAll];

(* Latitude *)
LAT = Flatten[Partition[datAll, 1, 7]];
datAll = RotateLeft[datAll];

(* SFC_SPD *)
SPD1 = Flatten[Partition[datAll, 1, 7]];
datAll = RotateLeft[datAll];

(* SPF_SPD _KT *)
SPD2 = Flatten[Partition[datAll, 1, 7]];
datAll = RotateLeft[datAll];

(* SFC_SPD _MP *)
SPD3 = Flatten[Partition[datAll, 1, 7]];
datAll = RotateLeft[datAll];

(* SFC_DIR *)
DIR = Flatten[Partition[datAll, 1, 7]];

(* Restore original list *)
datAll = datAllCpy;

(* Make longtitudes negative *)
LONG = Abs[LONG];
LONG = 0 - LONG;

(* Convert from degrees to radians *)
DIR = DIR *(2 Pi/360);

(* Graph data as vectors *)
xcor = LONG;
ycor = LAT;
xvc = SPD1*Cos[DIR]; 
yvc = SPD1*Sin[DIR];
vectors = Table[{{xcor[[i]], ycor[[i]]}, {-yvc[[i]], -xvc[[i]]}}, {i, 1, Length[xcor]}];

(* Calculate midpoint of data *)
midpoint = Flatten[Position[SPD1, 0.]][[1]];

(* Transpose all points to be around origin *)
LONGT = LONG - (LONG[[midpoint]]);
LATT = LAT - LAT[[midpoint]]; 

(* Graph data as vectors *)
xcorT = LONGT;
ycorT = LATT;
xvcT = SPD1*Cos[DIR]; 
yvcT = SPD1*Sin[DIR];
vectorsT = Table[{{xcorT[[i]], ycorT[[i]]}, {-yvcT[[i]], -xvcT[[i]]}}, {i, 1, Length[xcor]}];

v3 = ListStreamPlot[vectorsT, StreamStyle -> "Line", StreamPoints -> {{xcorT[[midpoint + 4]], ycorT[[midpoint + 4]]}}]

points = v3[[1, 2, 1]]; 

xPoints = Transpose[points][[1]]; 
yPoints = Transpose[points][[2]];

pointsOnly = ListPlot[Transpose[Join[{xPoints}, {yPoints}]]] ;

Show[v3, pointsOnly]
share|improve this question
1  
Please include full executable code so that we can try this ourselves without first having to recreate your example. –  Mr.Wizard Jan 22 '13 at 20:04
    
@Mr.Wizard Yes - I have added it above. –  ueronica Jan 22 '13 at 20:22
1  
Okay, but now we lack the test_data2b.txt file. Is it not possibly to give a smaller self-contained example of the problem? –  Mr.Wizard Jan 22 '13 at 20:24
    
Yes, just about to address that. The data can be found here - docs.google.com/document/d/… –  ueronica Jan 22 '13 at 20:32
add comment

2 Answers

up vote 3 down vote accepted

You can extract the Line first, then extract the points on the line:

pts = Cases[v3,
   GraphicsComplex[c__] :>
    Cases[Normal[GraphicsComplex[c]],
     Line[pts_] :> pts, Infinity],
   Infinity] // Flatten[#, 2]& ;
Graphics[{Red, Point[pts]}, Frame -> True ]

Mathematica graphics

share|improve this answer
    
Thanks so much! –  ueronica Jan 22 '13 at 22:21
    
@ueronica You're welcome :) –  Silvia Jan 22 '13 at 22:26
add comment

You could abuse the StreamColorFunction for this goal

res=
Reap[
  v3 = ListStreamPlot[vectorsT, 
          StreamStyle -> "Line", 
          StreamPoints -> {{xcorT[[midpoint + 4]], ycorT[[midpoint + 4]]}}, 
          StreamColorFunction -> ((Sow[{#1, #2}]; None) &)
       ]
];

ListPlot[res[[2]], AspectRatio -> Automatic]

Mathematica graphics

share|improve this answer
    
Thanks to you as well :) –  ueronica Jan 22 '13 at 22:28
add comment

Your Answer

 
discard

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.