Is this the sort of thing you wanted? It's pretty simple-
minded and hardly worth bothering you or the Forum
with.... code follows my sign-off.
usage:
dolindaplot ''
output: the plot you want and an smoutput line showing
which mask won.
Please note that I'm censoring earlier messages below.
Mike
dolindadata =: 3 : 0 NB. Globals still global
P=:1+?(2,8)$6
Q=:0 1{"1 P
MID=:-:+/"1 Q
MP=:-%/-/"1 Q
X1=:0
Y1=:(MP*( X1- 0{MID)) + 1{MID
Y2=:7
X2=:(Y2+(MP*0{MID)-1{MID)%MP
X3=:7
Y3=:(MP*( X3- 0{MID)) + 1{MID
Y4=:0
X4=:(Y4+(MP*0{MID)-1{MID)%MP
V=:Y1,X2,Y3,X4
POS=:(2=+/"1#:i.16)##:i.16
R=:|:(0,0,0, X2,7,7, 7,X4),.0,Y1,7,7, 7 , Y3,0,0
S=:(*./"2 (0<:R)*. R<:7)#"1 R
Y1=:(0>.Y1)
Y1=:(Y1<.7)
X2=:(0>.X2)
T1=:6($"1)3 5 4 {"1 S
T2=:6($"1)3 5 0 1 2 {"1 S
T3=:6($"1)5 2 3 4 {"1 S
T4=:6($"1)5 2 1 0 {"1 S
T5=:6($"1)2 4 3 {"1 S
T6=:6($"1)2 4 5 0 1 {"1 S
T7=:6($"1)1 5 0 {"1 S
T8=:6($"1)1 5 4 3 2 {"1 S
T9=:6($"1)1 4 3 2{"1 S
T10=:6($"1)1 4 5 0 {"1 S
T11=:6($"1)3 1 2 {"1 S
T12=:6($"1)3 1 0 5 4 {"1 S
T=:(T1,T2);(T3,T4);(T5,T6);(T7,T8);(T9,T10);(T11,T12)
TESTVP =: *./"1((0<:V)*.V<:7)="1 POS
)
dolindaplots=: 3 : 0
# dolindadata 1
for_i. i.#T do.
dat =.(<"2)>2 2$0 2 1 3 { >i{T
mask =. 1 i} 0#~#T
if. *./ mask = TESTVP do.
lindaplot dat;P
smoutput mask
end.
end.
''
)
lindaplot =: 3 : 0
'dat P'=. y
pd 'reset'
pd 'aspect 1'
pd 'type poly'
pd 'itemcolor blue, yellow, green, red'
pd dat
pd 'type marker'
pd 'markersize 1.2'
pd 'itemcolor black'
pd (<"1) 0 1 2{"1 P
pd 'show'
)
On 23/07/2012 11:39 AM, Linda Alvord wrote:
Can you help me show only the correct solution for this code. It is the one
image that is preceded by a 1. Any simplifications would be fun too.
load 'plot'
pd 'reset'
P=:1+?(2,8)$6
Q=:0 1{"1 P
MID=:-:+/"1 Q
MP=:-%/-/"1 Q
X1=:0
Y1=:(MP*( X1- 0{MID)) + 1{MID
Y2=:7
X2=:(Y2+(MP*0{MID)-1{MID)%MP
X3=:7
Y3=:(MP*( X3- 0{MID)) + 1{MID
Y4=:0
X4=:(Y4+(MP*0{MID)-1{MID)%MP
V=:Y1,X2,Y3,X4
POS=:(2=+/"1#:i.16)##:i.16
R=:|:(0,0,0, X2,7,7, 7,X4),.0,Y1,7,7, 7 , Y3,0,0
S=:(*./"2 (0<:R)*. R<:7)#"1 R
Y1=:(0>.Y1)
Y1=:(Y1<.7)
X2=:(0>.X2)
T1=:6($"1)3 5 4 {"1 S
T2=:6($"1)3 5 0 1 2 {"1 S
T3=:6($"1)5 2 3 4 {"1 S
T4=:6($"1)5 2 1 0 {"1 S
T5=:6($"1)2 4 3 {"1 S
T6=:6($"1)2 4 5 0 1 {"1 S
T7=:6($"1)1 5 0 {"1 S
T8=:6($"1)1 5 4 3 2 {"1 S
T9=:6($"1)1 4 3 2{"1 S
T10=:6($"1)1 4 5 0 {"1 S
T11=:6($"1)3 1 2 {"1 S
T12=:6($"1)3 1 0 5 4 {"1 S
dat=:(<"2)>2 2$0 2 1 3 { T1,T2
'aspect 1'plot dat
P
V
]*./ 1 0 0 0 0 0=*./"1((0<:V)*.V<:7)="1 POS
pd 'type poly'
pd 'itemcolor blue, yellow, green, red'
pd dat
pd 'type marker'
pd 'markersize 1.2'
pd 'itemcolor black'
pd (<"1) 0 1 2{"1 P
pd 'show'
]*./ 0 1 0 0 0 0=*./"1((0<:V)*.V<:7)="1 POS
dat=:(<"2)>2 2$0 2 1 3 { T3,T4
pd 'type poly'
pd 'itemcolor blue, yellow, green, red'
pd dat
pd 'type marker'
pd 'markersize 1.2'
pd 'itemcolor black'
pd (<"1) 0 1 2{"1 P
pd 'show'
]*./ 0 0 1 0 0 0=*./"1((0<:V)*.V<:7)="1 POS
dat=:(<"2)>2 2$0 2 1 3 { T5,T6
pd 'type poly'
pd 'itemcolor blue, yellow, green, red'
pd dat
pd 'type marker'
pd 'markersize 1.2'
pd 'itemcolor black'
pd (<"1) 0 1 2{"1 P
pd 'show'
]*./ 0 0 0 1 0 0=*./"1((0<:V)*.V<:7)="1 POS
dat=:(<"2)>2 2$0 2 1 3 { T7,T8
pd 'type poly'
pd 'itemcolor blue, yellow, green, red'
pd dat
pd 'type marker'
pd 'markersize 1.2'
pd 'itemcolor black'
pd (<"1) 0 1 2{"1 P
pd 'show'
]*./ 0 0 0 0 1 0=*./"1((0<:V)*.V<:7)="1 POS
]dat=:(<"2)>2 2$0 2 1 3 { T9,T10
pd 'type poly'
pd 'itemcolor blue, yellow, green, red'
pd dat
pd 'type marker'
pd 'markersize 1.2'
pd 'itemcolor black'
pd (<"1) 0 1 2{"1 P
pd 'show'
]*./ 0 0 0 0 0 1=*./"1((0<:V)*.V<:7)="1 POS
dat=:(<"2)>2 2$0 2 1 3 { T11,T12
pd 'type poly'
pd 'itemcolor blue, yellow, green, red'
pd dat
pd 'type marker'
pd 'markersize 1.2'
pd 'itemcolor black'
pd (<"1) 0 1 2{"1 P
pd 'show'
Linda
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm