Re: Easy colours? [message #82069] |
Thu, 15 November 2012 20:58  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 11/15/12 5:44 PM, David Fanning wrote:
> markjamie@gmail.com writes:
>
>> I often find myself needing to plot graphs (in direct or new graphics) for an unknown number of data series. To differentiate between them in the plot I colour each line / symbols. Since most of the time I have less than 10 series I usually just define an array of 10 specific colours and select from this on the plot command. However, this method has problems if you breach the number of pre-defined colours.
>>
>> Ideally, I'd like to be able to load a colour table and then have an easy way to select 'x' equally spaced colours across the colour table.
>>
>> For example, if my colour table went from blue-yellow-pink-green-red and I had 5 data series, I would like to be able to access each colour using a fractional number specifying how far across th colour table
>>
>> E.g.
>> Loadct,39
>> Plot, Series1, color=mycolour(0)
>> OPlot,Series2, color= mycolour(0.25)
>> OPlot,series3, color=mycolour(0.5)
>> OPlot,series4, color=mycolour(0.75)
>> OPlot,series5,color=mycolour(1)
>>
>> I've never found a way to do this in IDL - perhaps I'm missing something really simple...
>
> Loadct, 39, NCOLORS=NumberInSeries, BOTTOM=1
> mycolour = Bindgen(NumberInSeries)+1
>
> You might prefer to use cgLoadCT instead, since it has a
> CLIP keyword that is useful for trimming off colors at
> one or both ends of the color table before selecting
> the equally spaced colors.
>
> Cheers,
>
> David
>
Also, note that the "qualitative" (numbers 41 - 48) Color Brewer color
tables were designed for this type of task. They were added in IDL 8.2.1.
41 CB-Accent (8 colors)
42 CB-Dark2 (8 colors)
43 CB-Paired (12 colors)
44 CB-Pastel1 (9 colors)
45 CB-Pastel2 (8 colors)
46 CB-Set1 (9 colors)
47 CB-Set2 (8 colors)
48 CB-Set3 (12 colors)
Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Research Mathematician
Tech-X Corporation
|
|
|
Re: Easy colours? [message #82072 is a reply to message #82069] |
Thu, 15 November 2012 16:44   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
markjamie@gmail.com writes:
> I often find myself needing to plot graphs (in direct or new graphics) for an unknown number of data series. To differentiate between them in the plot I colour each line / symbols. Since most of the time I have less than 10 series I usually just define an array of 10 specific colours and select from this on the plot command. However, this method has problems if you breach the number of pre-defined colours.
>
> Ideally, I'd like to be able to load a colour table and then have an easy way to select 'x' equally spaced colours across the colour table.
>
> For example, if my colour table went from blue-yellow-pink-green-red and I had 5 data series, I would like to be able to access each colour using a fractional number specifying how far across th colour table
>
> E.g.
> Loadct,39
> Plot, Series1, color=mycolour(0)
> OPlot,Series2, color= mycolour(0.25)
> OPlot,series3, color=mycolour(0.5)
> OPlot,series4, color=mycolour(0.75)
> OPlot,series5,color=mycolour(1)
>
> I've never found a way to do this in IDL - perhaps I'm missing something really simple...
Loadct, 39, NCOLORS=NumberInSeries, BOTTOM=1
mycolour = Bindgen(NumberInSeries)+1
You might prefer to use cgLoadCT instead, since it has a
CLIP keyword that is useful for trimming off colors at
one or both ends of the color table before selecting
the equally spaced colors.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
|