!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! prop_prop_plot.jnl ! ! $Author: ansley $ ! $Date: 11-Jan-2008 ! 7/2010 ACM updates for V7.2 multi-variable plots ! prop_prop_plot.jnl creates a property-property plot, using the ! data variable in symbol data_0_var and the second variable from ! data_1_var, with its own full definition. ! The scatter plot is drawn using polygons, with options sent in for ! symbol_color, symbol_shape, and symbol_size. ! NOTE If the two variables are going to have DIFFERENT region settings, ! changes will need to be made to annotate that info on the plot. set mode ver:always IF `($data_count"0") LT 2` THEN MESSAGE/ERROR **ERROR Expecting two variables, but only received ($data_count) EXIT/PROGRAM ENDIF DEFINE SYMBOL its_prop_prop_plot = 1 ! used in setting titles and in RESULTS ! Define symbols associated with the region and data and perform any ! initialization needed for this dataset. GO LAS_initialize_region 0 GO LAS_initialize_data 0 ! Check for errors (They often occur during dataset initialization.) IF ($error_status"0|*>1") THEN MESSAGE/ERROR **ERROR ($error_string) EXIT/PROGRAM ENDIF ! Here is variable 0 title DEFINE SYMBOL ferret_title_0 = ($ferret_plot_title"($data_var)") DEFINE SYMBOL ferret_plot_var_0 = ($ferret_plot_var) IF ($do_curvi_xy"0|0|*>1") THEN DEFINE SYMBOL ferret_plot_var_0 = ($ferret_plot_base_var) IF ($do_curvi_xy"0|0|*>1") THEN DEFINE SYMBOL ferret_plot_var = ($ferret_plot_base_var) LET/TITLE="($ferret_title_0)" xvar = XSEQUENCE(($ferret_plot_var_0)) ! Set up upper-left labels with the region info GO LAS_pp_set_region_labels ! Initialize the second variable. ! In fact the region and dataset will be the ! same as for var 0 (for now anyway) GO LAS_initialize_region 1 GO LAS_initialize_data 1 IF ($error_status"0|*>1") THEN MESSAGE/ERROR **ERROR ($error_string) EXIT/PROGRAM ENDIF ! Here is variable 1 title DEFINE SYMBOL ferret_title_1 = ($ferret_plot_title"($data_var)") DEFINE SYMBOL ferret_plot_var_1 = ($ferret_plot_var) IF ($do_curvi_xy"0|0|*>1") THEN DEFINE SYMBOL ferret_plot_var_1 = ($ferret_plot_base_var) IF ($do_curvi_xy"0|0|*>1") THEN DEFINE SYMBOL ferret_plot_var = ($ferret_plot_base_var) DEFINE SYMBOL ferret_plot_var_1 = ($ferret_plot_var) GO LAS_set_strides_prop LET/TITLE="($ferret_title_0)" xvar = XSEQUENCE(($ferret_plot_var_0)) LET/TITLE="($ferret_title_1)" yvar = XSEQUENCE(($ferret_plot_var_1)) DEFINE SYMBOL xvar = xvar DEFINE SYMBOL yvar = yvar ! Apply any constraints IF ($constraint_0_lhs"0|*>1) THEN GO apply_pp_constraints 0 xvar DEFINE SYMBOL xvar = var_constr_0 GO apply_pp_constraints 1 yvar DEFINE SYMBOL yvar = var_constr_1 ENDIF ! The variables must be the same size. Check and set up a nice message if not. LET xsize = `($xvar),RETURN=isize` LET ysize = `($yvar),RETURN=isize` IF `xsize NE ysize` THEN MESSAGE/ERROR **ERROR The variables must have the same dimensions: ($data_0_var), ($data_1_var) EXIT/PROGRAM ENDIF IF `($data_count"0") EQ 3` THEN ! color by 3rd variable ! Initialize the 3rd variable. ! In fact the region and dataset will be the ! same as for var 0 (for now anyway) GO LAS_initialize_region 2 GO LAS_initialize_data 2 IF ($error_status"0|*>1") THEN MESSAGE/ERROR **ERROR ($error_string) EXIT/PROGRAM ENDIF ! Here is variable 2 title DEFINE SYMBOL ferret_title_2 = ($ferret_plot_title"($data_var)") IF ($do_curvi_xy"0|*>1") THEN DEFINE SYMBOL ferret_plot_var = ($ferret_plot_base_var_2) IF ($do_curvi_xy"0|*>1") THEN DEFINE SYMBOL ferret_plot_var_2 = ($ferret_plot_base_var_2) LET/TITLE="($ferret_title_2)" zvar = XSEQUENCE(($ferret_plot_var_2)) DEFINE SYMBOL color_by = 1 ENDIF ! Open the window, apply size, scale options ! dont want to set the aspect ratio using xy region, so reset ! ferret_view temporarily. DEFINE SYMBOL viewsave = ($ferret_view) DEFINE SYMBOL ferret_view = aa GO LAS_open_window DEFINE SYMBOL ferret_view = ($viewsave) ! Build up the plot qualifiers IF ($ferret_use_graticules"0|0|*>1) THEN SET MODE GRATICULE:(DASH,COLOR=black) ENDIF ! This is going to be a polygon plot. Options for color, shape, size. DEFINE SYMBOL polycolor = ($ferret_symbol_color%black|default>black|black|red|blue|green|lightblue|purple|*>blue%) DEFINE SYMBOL polysize = ($ferret_symbol_size%0.6|default>*0.6|*%) DEFINE SYMBOL polyshape = ($ferret_symbol_shape%triangle|default>triangle|triangle|delta\ |square|diamond|pentagon|hexagon|circle|star|plus|ex|*>triangle%) DEFINE SYMBOL ferret_plot_title = " " ! Set the plot argument. DEFINE SYMBOL plot_arg = ($xvar), ($yvar) ! The underlying plot is a PLOT/VS DEFINE SYMBOL qualifiers = ($qualifiers)/VS/COLOR=WHITE ! Expand the horizontal and vertical scale a bit data is not on top of ! the plot axes. STAT ($xvar) PPL %RANGE `($stat_min)`, `($stat_max)`, 10 IF `($ppl$range_high) EQ ($ppl$range_low)` THEN DEFINE SYMBOL ppl$range_low = `($ppl$range_low) - 1` DEFINE SYMBOL ppl$range_high = `($ppl$range_high) + 1` DEFINE SYMBOL ppl$range_inc = 1 ENDIF DEFINE SYMBOL ferret_indep_axis_scale ($ppl$range_low),($ppl$range_high),($ppl$range_inc) DEFINE SYMBOL qualifiers ($qualifiers)/HLIM=($ppl$range_low):($ppl$range_high) STAT ($yvar) PPL %RANGE `($stat_min)`, `($stat_max)`, 10 IF `($ppl$range_high) EQ ($ppl$range_low)` THEN DEFINE SYMBOL ppl$range_low = `($ppl$range_low) - 1` DEFINE SYMBOL ppl$range_high = `($ppl$range_high) + 1` DEFINE SYMBOL ppl$range_inc = 1 ENDIF DEFINE SYMBOL ferret_dep_axis_scale ($ppl$range_low),($ppl$range_high),($ppl$range_inc) DEFINE SYMBOL qualifiers ($qualifiers)/VLIM=($ppl$range_low):($ppl$range_high) DEFINE SYMBOL qualifiers ($qualifiers)/NOKEY/NOLAB ! Draw the plot underlay PLOT($qualifiers)/TITLE="($ferret_title)" ($plot_arg) LABEL/NOUSER `($ppl$xlen)/2`, -0.6, 0, 0, 0.14 ($ferret_title_0) LABEL/NOUSER -0.8, `($ppl$ylen)/2`, 0, 90, 0.14 ($ferret_title_1) ! add any constraint labels in the lower left. IF `($nmask_labels"0|*>1") EQ 0` THEN DEFINE SYMBOL nmask_labels = 1 IF `($nmask_labels) GT 2` THEN DEFINE SYMBOL nmask_labels = 2 DEFINE SYMBOL label_y = `-0.95*($ppl$yorg) + 0.2*(($nmask_labels)-1)` DEFINE SYMBOL label_x = `-0.95*($ppl$xorg)` DEFINE SYMBOL label_y = `-0.95*($ppl$yorg) + 0.2*(($nmask_labels)-1)` REPEAT/RANGE=1:`($nmask_labels)`:1/NAME=m (\ DEFINE SYMBOL mmask = `m`;\ IF ($mask_title_($mmask)"0|*>1) THEN ; \ LABEL/NOUSER `($label_x)`, `($label_y)`, -1, 0, 0.12, ($mask_title_($mmask)) ; \ DEFINE SYMBOL label_y = `($label_y) - 0.2`; \ ENDIF \ ) ! Polygon plot DEFINE SYMBOL plot_arg = ($xvar), ($yvar), ($xvar) DEFINE SYMBOL poly_qual = /OVER/NOLAB IF ($color_by"0|*>1") THEN DEFINE SYMBOL plot_arg = ($xvar), ($yvar), zvar ! Get color-plot qualifiers IF ($ferret_fill_levels"0|*>1") THEN DEFINE SYMBOL poly_qual = ($poly_qual)/LEVELS=($ferret_fill_levels) ELSE DEFINE SYMBOL poly_qual = ($poly_qual)/LEVELS=v ENDIF IF ($ferret_plot_key"0|0|nokey>1|*>0") THEN DEFINE SYMBOL poly_qual = ($poly_qual)/NOKEY ELSE DEFINE SYMBOL poly_qual = ($poly_qual)/KEY ENDIF ! Dont use the palette coming in. Its for variable 0 DEFINE SYMBOL poly_qual = ($poly_qual)/PALETTE=($ferret_palette"rainbow|default>rainbow|*>*) DEFINE SYMBOL poly_qual = ($poly_qual)/PALETTE=rainbow DEFINE SYMBOL color_by_title = `zvar,RETURN=title` ELSE DEFINE SYMBOL poly_qual = ($poly_qual)/palette=($polycolor) ENDIF DEFINE SYMBOL poly_command POLYGON($poly_qual) GO polymark ($poly_command) ($plot_arg), ($polyshape), ($polysize) IF ($color_by_title"0|*>1") THEN LABEL/NOUSER `($ppl$width)-($ppl$xorg)-0.2`, -0.7, 1, 0, 0.12 Colored by ($color_by_title) ! Add the linear fit information ! Gaps in p and qhat mean that just plotting p, qhat ! may result in a gappy or invisible line. Plot between the ! first and last good point instead. ! variables for the regression line LET p = ($xvar) ! for regression line LET q = ($yvar) LET do_rsquare = 1 DEFINE SYMBOL line_color = blue ! regression line IF ($polycolor%0|blue>1|*>0%) THEN DEFINE SYMBOL line_color = red GO regressx IF `(p[x=@NGD] LE 1) OR (qhat[x=@NGD] LE 1)` THEN DEFINE SYMBOL do_rsquare = 0 IF ($do_rsquare"1|0|*>1) THEN ! Note that qhat in the regress script is defined as ! LET qhat = slope*p + intercep ! If one of p or q has lots of missing values this can look wierd LET qhatmasked = slope*pmasked + intercep LET pminmax = MINMAX(pmasked) LOAD pminmax LET p1 = `pminmax[i=1]` LET p2 = `pminmax[i=2]` LET qminmax = MINMAX(qhatmasked) LOAD qminmax LET q1 = `qminmax[i=1]` LET q2 = `qminmax[i=2]` IF `slope LT 0` THEN LET qtmp = `q2` LET q2 = `q1` LET q1 = `qtmp` ENDIF PLOT/VS/OVER/NOLAB/LINE/THICK=2/color=($line_color) {`p1`,`p2`}, {`q1`,`q2`} ! Label the rsquare and slope of the line. Put this above the plot. IF `rsquare` THEN LABEL/NOUSER `($ppl$xlen)-0.2`,`($ppl$ylen)+0.25`,1, 0, 0.10, @P4@SRR^2 = `rsquare,P=3` LABEL/NOUSER `($ppl$xlen)-0.2`,`($ppl$ylen)+0.1`,1, 0, 0.10, @P4@SRSlope = `slope,P=3` ENDIF ENDIF ! Add labels at the top of the plot GO LAS_url_label 0 IF `($n_right_labels"0") GT 0 OR ($n_left_labels"0") GT 0` THEN GO labels_above_plot ! Overall header at the very top GO LAS_ferret_las_version_header ! Save the results GO LAS_results box ! ----- End of prop_prop_plot.jnl ------------------------------------------------