Solved the problem by using object array. Pasting the plotting section of my code. Not necessarily the best solution but it works for me.
oPlotArr = OBJARR(num_param*num_ang*num_mat)
graphProps = {props, color:'blue', linestyle:'dashed', symbol:'triangle', thick:2}
PropsArr = REPLICATE({props}, num_mat)
PropsArr[0] = {color:'blue', linestyle:'dashed', symbol:'triangle', thick:2}
PropsArr[1] = {color:'green', linestyle:'solid_line', symbol:'plus', thick:2}
PropsArr[2] = {color:'red', linestyle:'dash dot', symbol:'X', thick:2}
Yaxislabel = ['Pen / Geo', 'Sc / Geo']
win = WINDOW()
FOR i = 0, num_param-1 DO BEGIN
FOREACH AngleEl, Angles, Angle_indx DO BEGIN
CurAngleEl = WHERE(AcceptAngle EQ AngleEl)
FOREACH MatEl, Materials, Mat_indx DO BEGIN
CurMatEl = WHERE(Material EQ MatEl AND AcceptAngle EQ AngleEl)
CurIndx = i*num_ang*num_mat+Angle_indx*num_mat+Mat_indx
OverPlotIndx = i*num_ang*num_mat+Angle_indx*num_mat
IF Mat_indx EQ 0 THEN BEGIN
oPlotArr(CurIndx) = PLOT(PinSizes, ResMat(i, CurMatEl), $
LAYOUT = [num_ang,num_param,(i*3+Angle_indx)+1] , /CURRENT, $
_EXTRA = PropsArr(Mat_indx), TITLE = '$\alpha$: ' + STRING(AngleEl, FORMAT='(I2.2)' ), $
YTITLE = Yaxislabel[(i*3+Angle_indx)/num_ang], XTITLE= 'Pinhole Size, mm' )
ENDIF ELSE BEGIN
oPlotArr(CurIndx) = PLOT(PinSizes, ResMat(i, CurMatEl), $
LAYOUT = [num_ang,num_param,(i*3+Angle_indx)+1] , OVERPLOT = oPlotArr(OverPlotIndx), $
_EXTRA = PropsArr(Mat_indx) )
ENDELSE
ENDFOREACH
leg = LEGEND(TARGET=[oPlotArr(CurIndx-mat_indx+1:CurIndx)] )
FOREACH legEl, Materials, leg_indx DO leg(leg_indx).label = Materials(leg_indx)
ENDFOREACH
ENDFOR
|