Re: ListPlot - assigning a list of colors to a set of

• To: mathgroup at smc.vnet.net
• Subject: [mg131967] Re: ListPlot - assigning a list of colors to a set of
• From: Tomas Garza <tgarza10 at msn.com>
• Date: Wed, 6 Nov 2013 00:39:24 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-outx@smc.vnet.net
• Delivered-to: mathgroup-newsendx@smc.vnet.net
• References: <20131105041619.448C769FC@smc.vnet.net>

```Perhaps a quick way (which may be enormously improved) would be to first split your points according to their labels, produce the corresponding plots, and Show them together at the end. Using your example,
p1 = ListPlot[{{1, 1}}, PlotStyle -> {Red, PointSize[0.02]}, PlotRange->{{0,4},{0,4}};p2 = ListPlot[{{2, 2}}, PlotStyle -> {Green, PointSize[0.02]}];
p3 = ListPlot[{{3, 3}}, PlotStyle -> {Blue, PointSize[0.02]}];

Show[p1, p2, p3}

-Tomas

> From: grobertson at bcgsc.ca
> Subject: ListPlot - assigning a list of colors to a set of points
> To: mathgroup at smc.vnet.net
> Date: Mon, 4 Nov 2013 23:16:19 -0500
>
>
> I'm using Mathematica v9.x on a Mac, with OS X 10.7.5.
>
> Could I ask about something that likely has a very simple solution? I have a list of XY coordinates for say 500 points that will become a scatterplot via ListPlot. I need to assign a colour to each point, using a list of labels (histology, risk, =85).
>
> I've generated ArrayPlot graphics for cases like this for some time. For example, given some labels in column 4 of a 'hist' table:
> colours = Table[{
>     Switch[name = hist[[i, 4]],
>      "Classical", Green, "Tall cell", Red, "Other", Blue]
>     }, {i, Length[hist]}];
>  ArrayPlot[{colours}, AspectRatio -> 0.1, Frame -> False]
>
> For a ListPlot, I'd have thought that something as simple as dropping a list of colours into a PlotStyle Directive would do the job. But the following line plots three blue points, rather than a Red, Green and Blue point.
> ListPlot[{{1, 1}, {2, 2}, {3, 3}},
>  PlotStyle -> Directive[PointSize[0.02], {Red, Green, Blue}]]
>
> Is there a simple way to declare a list of colours in ListPlot? I've looked through the PlotStyle documentation, and apologize if I've missed seeing how to do this.
>
> Thanks very much for your help.
>
> Gordon
> --
> Gordon Robertson
> Michael Smith Genome Sciences Centre
> BC Cancer Agency