Hello John,
On 26.05.06, John Owens wrote:
> --- John Owens <[EMAIL PROTECTED]> wrote:
>
> Here's the support I want to add. palette.select() appears to be the right
> interface for it, I think, so that's specifically what I'm hoping to see
> sample
> code for.
> The folks at colorbrewer.org have spent a lot of time finding good palettes
> for drawing. The interface is palette[name][number], where 'name' is a
> specific palette ("accent", "blues", etc.) and 'number' is the number of
> different items that need to be drawn. That's exactly what select() does.
>
> I'd like to create a data structure that looks something like:
>
> palette['accent'][3] = [ rgb(RR, GG, BB), rgb(RR, GG, BB), rgb(RR, GG, BB) ]
> palette['accent'][4] = [ rgb(RR, GG, BB), rgb(RR, GG, BB), rgb(RR, GG, BB),
> rgb(RR, GG, BB) ]
> ...
> where I fill in all the RR, GG, and BBs. But I don't know how to use the
> select call (or another call) that will let the palette automatically choose
> the right 'number' based on the number of drawn items and then pick
> the right colors from that.
All PyX palettes internally use a real parameter between 0 and 1. The
color values are defined in terms of continuous functions. What you
want to do here, is rather a discrete definition of the palette.
In order to convince PyX to use your color values, you have to do the
following: Define functions function which interpolates all the RGB values
from colorbrewer. This can either be a simple piecewise linear
function or, better, a smooth approximation to it.
Then take these three functions (one for each RGB value) and define
a functionpalette with it, call it "accentpalette", if you like.
Instead of
palette['accent'][3]
you have to say
accentpalette.select(3, N)
where N is the total number of colors you need from the palette.
Michael.
--
"A mathematician is a device for turning coffee into theorems"
Paul Erdös.
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user