Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #16160 > unrolled thread

ListPlot - assigning a list of colors to a set of points

Started byGordon Robertson <grobertson@bcgsc.ca>
First post2013-11-05 04:10 +0000
Last post2013-11-06 05:29 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  ListPlot - assigning a list of colors to a set of points Gordon Robertson <grobertson@bcgsc.ca> - 2013-11-05 04:10 +0000
    Re: ListPlot - assigning a list of colors to a set of points Helen Read <readhpr@gmail.com> - 2013-11-06 05:20 +0000
    Re: ListPlot - assigning a list of colors to a set of points Joe Gwinn <joegwinn@comcast.net> - 2013-11-06 05:29 +0000

#16160 — ListPlot - assigning a list of colors to a set of points

FromGordon Robertson <grobertson@bcgsc.ca>
Date2013-11-05 04:10 +0000
SubjectListPlot - assigning a list of colors to a set of points
Message-ID<l59r3a$rcm$1@smc.vnet.net>
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
Vancouver BC Canada
www.bcgsc.ca<http://www.bcgsc.ca>

[toc] | [next] | [standalone]


#16173

FromHelen Read <readhpr@gmail.com>
Date2013-11-06 05:20 +0000
Message-ID<l5cji4$4pq$1@smc.vnet.net>
In reply to#16160
Make each point a sublist (i.e, enclose in an extra set of braces).

ListPlot[{{{1, 1}}, {{2, 2}}, {{3, 3}}},
  PlotStyle -> {{PointSize[0.02], Red}, {PointSize[0.02],
     Green}, {PointSize[0.02], Blue}}]

Helen Read
University of Vermont

On 11/4/2013 11:10 PM, Gordon Robertson wrote:
> 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
> Vancouver BC Canada
> www.bcgsc.ca<http://www.bcgsc.ca>
>


[toc] | [prev] | [next] | [standalone]


#16187

FromJoe Gwinn <joegwinn@comcast.net>
Date2013-11-06 05:29 +0000
Message-ID<l5ck3b$4rr$1@smc.vnet.net>
In reply to#16160
In article <l59r3a$rcm$1@smc.vnet.net>, Gordon Robertson
<grobertson@bcgsc.ca> wrote:

> 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.

I never did figure out how to do that with ListPlot, and Tech Support
didn't know of a way either, so I built the plot-list directly, as a
Graphics[] object, and then used Show[] to display it, and to overlay
the colored dots on various function lines from ListPlot.

Joe Gwinn

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web