Ok! (Picking colors for graphs is not a topic I have spent much time
on, I'll mostly just listen on this topic.)

But when I ran your code, I got an error. Here's my fix:

   roundNums=: <.@+&0.5

Thanks,

-- 
Raul

On Mon, Aug 12, 2013 at 1:20 PM, Devon McCormick <[email protected]> wrote:
> I think this is a good simplification of what I want to do.  I believe I
> copied the code from Cliff a long time ago, when I didn't know J very well,
> and re-wrote it in APL for the paper.
>
> My intention was to come up with a good palette for graphing values.  I
> wanted a logical progression of distinct colors, for some value of
> "logical", with more colors in some parts of the range.  Actually, looking
> at the code I currently use to generate my favored palette, it looks like I
> already abandoned the "pwlin" code.
>
> Here's what I do, using your version of interpolation since it's simpler
> than the one I currently use:
>
>    interpolatePts=: 4 : '([+"1((<:x)%~i.x)*/-~)/y'
>    interpolatePtPairs=: 4 : '({:y),~;}:&.>x interpolatePts&.>2<\y'
>    CORNERS=: 0 4 2 1 6 5 3 7 {255*2 2 2#:i.8
> NB.* FULLSPECPAL: black->dark
> blue->green->cyan->purple->red->orange->yellow->almost white
>    FULLSPECPAL=: 256{. <.0.5+24 36 46 40 40 50 30 interpolatePtPairs (0 3 2
> 6 5 1 4 7){CORNERS
>
> You can see what this looks like with
>    FULLSPECPAL viewmat i.16 16
>
> The palette I use as my default further tinkers with this as shown here:
>
> NB.* adjustFullSpectrumPalette: make full-spectrum palette better...
> adjustFullSpectrumPalette=: 3 : 0
>    len=. #ix=. 80+i.56                  NB. Adjust the mid-palette to elim
> NB.   ((<:<./ix),>:>./ix){FULLSPECPAL   NB.  cyan because it's too light at
> NB.   0 255 103                         NB.  transition and too similar to
> NB. 187  68 255                         NB.  blue at low end of palette.
>    pb=. |:FULLSPECPAL{~({.,{:) ix       NB. Patch borders
>    patch=. stepsftn"1]pb,.len           NB. Linear-match RGB each to within
> 2
>    bv=. -:|.(]%~[:>:i.)len              NB. Blend-vec: push patch toward
> gray,
>    patch=. |:roundNums (>:bv)%"1~patch+"1 bv*128  NB. strongly->weakly
>    ADJPAL=: patch ix}FULLSPECPAL
> )
>
> Where "stepsftn" is this:
>
>  stepsftn=: 3 : 0
> NB.* stepsftn: vector of numbers from num, to num, in numsteps steps.
>    'from to numsteps'=. y
>    from+(to-from)*(numsteps-1)%~i.numsteps
> )
>
> For some other palettes, I just use this last verb:
>
> NB.* BGYPAL: Blue->Green->Yellow palettes (hand-done)
> NB. These palettes keep down the number of different colors to reduce
> NB. the "busyness" of a graph.  Also, they vary smoothly from dark to
> NB. light so will stay distinct when printing in black & white.
>
> BGYPAL=: ;stepsftn&.>0 0 86;64 127 85;120 200 43;220 255 42 NB. Red,
> BGYPAL=: BGYPAL,:;stepsftn&.>0 80 85;96 224 86;230 255 85   NB. Green,
> BGYPAL=: BGYPAL,;stepsftn&.>0 255 75;250 112 95;64 128 86   NB. Blue
> BGYPAL=: roundNums |:BGYPAL
>
>
>
> On Sun, Aug 11, 2013 at 10:37 PM, Raul Miller <[email protected]> wrote:
>
>> Ok... but if that is all you want, then this kind of expression will do it:
>>    (([+"1(85%~i.86)*/-~)/)"2
>>
>> For example:
>>    (([+"1(3%~i.4)*/-~)/)"2 (1 0 0,:0 1 0)
>>        1        0 0
>> 0.666667 0.333333 0
>> 0.333333 0.666667 0
>>        0        1 0
>>
>> Or, if you prefer:
>>    1 0 0 ([+"1(3%~i.4)*/-~)0 1 0
>>
>> (same result)
>>
>> But I guess I am trying to understand what kind of more general
>> framework you want to put this kind of operation into?
>>
>> Thanks,
>>
>> --
>> Raul
>>
>> On Sun, Aug 11, 2013 at 10:30 PM, Devon McCormick <[email protected]>
>> wrote:
>> > Because (with the linear interpolation) it gives me gradations of colors
>> > across the full range of colors available (or less than the full range
>> if I
>> > wanted to choose a limited number of points).
>> >
>> >
>> > On Sun, Aug 11, 2013 at 7:10 PM, Raul Miller <[email protected]>
>> wrote:
>> >
>> >> On Sun, Aug 11, 2013 at 5:50 PM, Devon McCormick <[email protected]>
>> >> wrote:
>> >> > The reason I like Cliff's code is it lets me draw lines through the
>> color
>> >> > cube between arbitrary corners.
>> >>
>> >> How is this useful?
>> >>
>> >> Thanks,
>> >>
>> >> --
>> >> Raul
>> >> ----------------------------------------------------------------------
>> >> For information about J forums see http://www.jsoftware.com/forums.htm
>> >>
>> >
>> >
>> >
>> > --
>> > Devon McCormick, CFA
>> > ^me^ at acm.
>> > org is my
>> > preferred e-mail
>> > ----------------------------------------------------------------------
>> > For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
>
>
> --
> Devon McCormick, CFA
> ^me^ at acm.
> org is my
> preferred e-mail
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to