The plot source was embarrassingly easy to change. Sorry for taking people's time on something I could have changed with a little thought. If someone else has the need for multicoloured stick plots, this is what needs to be changed in jzplot.ijs

plot_stick=: 3 : 0
dat=. getgrafmat y
dat=. _2 (4&$)\ ,dat
ydiv=. fitgrafy YDiv
dat=. ydiv 3 }"1 dat
NB. drawline iDATA;(getitemcolor'');PENSIZE;dat
drawline iDATA;(getitemcolor #dat);PENSIZE;dat  NB. modified
)


Sean

Sean O'Byrne wrote:

Thanks for your suggestion, Raul.
By the way, plot otherwise works just fine on Linux for me.

You certainly weren't suggesting something stupid. With some modification, I got it to do roughly what I want. Your code, as written, still plots everything in the one colour: this is because my data is plotted in x;y form. I get multiple colours if I just plot the matrix and use the ordinate for x. I was able to modify your idea to do what I wanted with the following code

colours =: ' blue',' red', ' green' ,' yellow' ,: ' magenta'

pdrow =: dyad define
'maty colours' =. y
pd 'color ',colours
pd x;maty
)

stickplot =: 3 : 0
'matx maty' =: y
nplots =: <./ (# maty), # colours
pd&> 'reset';'type stick';'pensize 2'
matx (pdrow"1) (nplots{.maty)(;"1)nplots{.colours
pd 'show'
)

NB. to test, use something like stickplot (1 2 3); 1 2 3, 2 1 6,: 3 0 9


This works, but it is not trivial to do things like add a key. Again, this probably just illustrates that I don't have enough mastery over rank to work out how to do things like that in a 'clean' way. I still wish that 'stick' plot worked like the other types. Both 2-d and 3-d versions appear to print in one colour for multiple plots. I'll have a look at the plot source and see if I can work out why.

Sean

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to