There is an easier way to handle this without changing the plot class.
Since we know that plot indexes colors as needed, then you can
programmatically build up the colors to match the data.

For example, this example recycles colors starting from the beginning for
each block of data:

load 'plot'
'dat1 dat2 dat3'=. 10 #&> each 1 2 3;4 5 6 7;8 9
clr1=: (#dat1) {. STDCLR_jzplot_
clr2=: (#dat2) {. STDCLR_jzplot_
clr3=: (#dat3) {. STDCLR_jzplot_
pd 'itemcolor ',":,clr1,clr2,clr3
pd 'pensize 5'
pd dat1
pd dat2
pd dat3
pd 'show'

On Mon, Jul 17, 2017 at 10:00 AM, chris burke <[email protected]> wrote:

> Plot just recycles colors as needed. You can reset the item colors
> anytime, but the colors are indexed by the current data item so this is not
> what you want. I don't think there is a built-in way to override this.
>
> However, the function that indexes the colors is just:
>
>    getitemcolor_jzplot_
> 3 : 'y $ DataNdx |. ITEMCOLOR'
>
> If you remove the "DataNdx |." expression, then you can reset item colors
> the way you expect. For example, try:
>
> load 'plot'
> getitemcolor_jzplot_=: 3 : 'y $ ITEMCOLOR'
> dat=: 10#&>1+i.9
> pd 'pensize 5'
> pd 'itemcolor red,blue,green'
> pd 0 1 2 { dat
> pd 'itemcolor yellow,magenta,lime,brown'
> pd 3 4 5 6 { dat
> pd 'itemcolor orange,darkblue'
> pd 7 8 { dat
> pd 'show'
>
> Of course, this does change the plot class. For later use in the same
> session, you can restore the definition, or reload with:
>
>    load 'jzplot'
>
>
> On Mon, Jul 17, 2017 at 8:06 AM, Rudolf Sykora <[email protected]>
> wrote:
>
>> On 17 July 2017 at 16:42, Tom Arneson <[email protected]> wrote:
>>
>> > To get just 4 colors, redefine STDCLR
>> >
>> > STDCLR_jzplot_=: 4{. STDCLR_jzplot_
>>
>> Say I do not know in advance how many graphs will be there.
>> (I know I can always count them, but...)
>>
>> Say the number of plotted lines in the 1st and 2nd group (see below)
>> are not the same.
>> Do I really need to count and define itemcolor list for each one plot
>> "set", a, b below?:
>>
>> pd i.3        NB. 1a
>> pd 1+i.3   NB. 2a
>> pd 2+i.3   NB. 3a
>> ...
>> pd N+i.3   NB.Na
>>
>> NB. reset colors-chain somehow here
>>
>> pd *: i.3   NB. 1b
>> pd % i.3  NB. 2b
>> ...
>> pd foo i.3  NB.Mb
>>
>> I want the graphs 1a,1b and 2a,2b and 3a,3b etc. have the same color, N
>> and M
>> don't have to be the same, the colour-chain length can have its own
>> length.
>> As I said, I thought something like
>>
>> MY_z =: STDCLR_jwplot_
>> pd 'itemcolor MY'
>>
>> would do it (when put between the two groups), but for some reason
>> it does not work.
>>
>> Thanks
>> Ruda
>> ----------------------------------------------------------------------
>> 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