SAS: change the colour and thickness of the reference label in proc gplot

1k Views Asked by At

I am trying to plot the different levels of salary in a needle plot and I'd like a reference line. The following code provides this reference line but the line is the same colour as the needles and is too thin. Is there a way to change this?

SYMBOL1
    INTERPOL=NEEDLE
    HEIGHT=10pt
    VALUE=NONE
    LINE=1
    WIDTH=2
    CV = _STYLE_
;
Axis1
    STYLE=1
    WIDTH=1
    MINOR=NONE
    REFLABEL=(j=c color = red width = 5 '');
;
Axis2
    STYLE=1
    WIDTH=1
    MINOR=NONE
;
TITLE;
TITLE1 "Bootstrap: Needle Plot of log salary";
PROC GPLOT 
    DATA = sashelp.baseball
    ;
    PLOT logsalary * name /
        VAXIS = AXIS1
        HAXIS = AXIS2
        VREF  = 4
    ;
RUN; QUIT;
1

There are 1 best solutions below

2
On BEST ANSWER

The color and width of the reference line(s) are controlled by the enumeration lists on the VREF, CVREF and WVREF options of the PLOT statement. The labels and colors of the reference lines have to be manually aligned with similar enumeration lists in the AXIS statement.

Additional control over the plotting process can be done with annotation data sets. In particular, annotations can be specified to be drawn after the procedure completes its drawing, with the result of the renderings to appear on top of the procedure output.

Example

SYMBOL1 INTERPOL=NEEDLE HEIGHT=10pt VALUE=NONE LINE=1WIDTH=2 CV = _STYLE_ ;

Axis1 order = 0 to 10 STYLE=1 WIDTH=1 MINOR=NONE
    REFLABEL = 
      ( j=c color=RED height=4 "HELLO"     /* labels for two reference lines */
        j=l color=BLUE height=3 "EIGHT"  
      );
Axis2 STYLE=1 WIDTH=1 MINOR=NONE ;

TITLE;
TITLE1 "Bootstrap: Needle Plot of log salary";

options mprint;

DATA anno;
   %annomac;
   when = 'After';
   %system (1,2,4)
   %line (0,1, 100,1, GREEN, 0, 6)
   %label (30, 1.2, "LABEL AFTER", GREEN, 0, 0, 4, , B)
/* %LABEL (x, y, text-string, color, angle, rotate, size, style, position); */
RUN;

PROC GPLOT 
    DATA = sashelp.baseball(obs=20)
    ANNO = anno
    ;
    PLOT logsalary * name /
        VAXIS = AXIS1
        HAXIS = AXIS2

           VREF = ( 4  8 )         /* axial data value of reference lines */
          WVREF = ( 4  6 )         /* Width and colors of reference lines */
          CVREF = ( RED BLUE )
    ;
run;quit;