Search code examples
templatesgraphsasheatmapsas-gtl

Add Reference Lines to SAS Heatmap


I am making heatmaps through SAS. I would like to add reference reference lines (a horizontal and vertical) to the heatmap that split it up into quadrants. My code right now looks like this:

proc template;
  define statgraph heatmapparm;
    begingraph;
      layout overlay;
         heatmapparm x=X_Value y=Y_Value colorresponse=percent / colormodel=(blue yellow red)
          name="heatmapparm" xbinaxis=false ybinaxis=false datatransparency=0;
        continuouslegend "heatmapparm" / location=outside valign=bottom;
      endlayout;
    endgraph;
  end;
run;

proc sgrender data=Data template=heatmapparm;
run;

This graphs a heatmap of the X and Y variables, but I would like add cross lines to mark the middle of my graph. Thanks!!


Solution

  • Try the drawline statement.

    http://support.sas.com/documentation/cdl/en/grstatgraph/65377/HTML/default/viewer.htm#n19cwbtkb5cslcn1bk80pgw2wxex.htm

    This adds lines to the heatmap example from the doc:

    proc template;
      define statgraph heatmapparm;
        begingraph;
          layout overlay;
            heatmapparm x=height y=weight colorresponse=count /
              name="heatmapparm" xbinaxis=false ybinaxis=false;
            drawline x1=50 y1=0 x2=50 y2=100 /
              x1space=wallpercent y1space=wallpercent
              x2space=wallpercent y2space=wallpercent
              lineattrs=GraphReference  ;
            drawline x1=0 y1=50 x2=100 y2=50 /
              x1space=wallpercent y1space=wallpercent
              x2space=wallpercent y2space=wallpercent
              lineattrs=GraphReference  ;
            continuouslegend "heatmapparm" / location=outside valign=bottom;
          endlayout;
        endgraph;
      end;
    run;
    
    proc sgrender data=sashelp.gridded template=heatmapparm;
    run;