# ListPlot with conditions

I have a data file containing the position of about $10^5$ stars of a spiral galaxy. Here is the plot

and this is the corresponding code

Clear["Global*"]
SetDirectory[" ... "];

data = Import["data_SGC.out", "Table"];
L0 = ListPlot[data, PlotStyle -> {Blue, PointSize[0.001]}, Axes -> False,
Frame -> True, FrameLabel -> {"x", "y"},
RotateLabel -> False, LabelStyle -> Directive[FontFamily -> "Helvetica", 20],
AspectRatio -> 1, PlotRange -> 100, ImageSize -> 550];


As we can see, there are two arms starting at about $(x,y) = (-14.6,0)$ and $(x,y) = (14.6,0)$. Now I would like to customize ListPLot, so as the arm starting at the left part $(x,y) = (-14.6,0)$, be in green color, while the other one in red. All the other points between the two yellow banana-type areas should be in gray.

Any suggestions?

The complete data file can be found here: data. Obviously, I could not generate simple random data in order to replicate this complicated spiral structure.

-
So if it's just about the ListPlot, do we need all the ContourPlot and RegionPlot? I guess data = Import[..] and ListPlot[...] would be enough. – Öskå Jul 31 '14 at 9:40
@Öskå You are right, ContourPlot and RegionPlot are not needed, so I removed them. See the revised post. – Vaggelis_Z Jul 31 '14 at 9:44
At least now one can read the text and see the picture in the same time :) – Öskå Jul 31 '14 at 9:48

You have somehow to segment your data. Here you could use the radius + FindClusters:

    radius = 14.6;
data1 = FindClusters[Select[data, Norm[#] > radius &], 2,Method -> "Agglomerate"];
Show[
ListPlot[data1, PlotRange -> Full, AspectRatio -> 1, PlotStyle -> {Green, Red}],
ListPlot[Select[data, Norm[#] < radius &], PlotRange -> Full, AspectRatio -> 1, PlotStyle -> Gray]
]


This will give you something like this:

-
That's exactly what I was looking for! One minor detail. How can I set correctly PointSize[0.001] to all three lists (gree, red, gray)? – Vaggelis_Z Jul 31 '14 at 14:32
Disregard my last comment. I found the solution. PlotStyle -> {Directive[Darker[Green], PointSize[0.001]], Directive[Red, PointSize[0.001]]}] – Vaggelis_Z Jul 31 '14 at 14:37
@Öskå Yes it was very easy to set the correct PointSize`. – Vaggelis_Z Jul 31 '14 at 14:38
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.3662562966346741, "perplexity": 1739.597962686297}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2016-18/segments/1461860117244.29/warc/CC-MAIN-20160428161517-00051-ip-10-239-7-51.ec2.internal.warc.gz"}