SAS: Remove Dashes From Legend Symbols When Using Interpol

207 views Asked by At

I've got my plot looking pretty, but the fly in the ointment is the legend. When I connect the data points on my plot using interpol = join, SAS puts a little dash on each symbol in the legend.

Legend with dashes

Without interpol = join, the legend looks nice and clean.

Legend without dashes

Is there a simple way to remove the dashes from the legend while still connecting my data points?

data _nodes;
  input 
    group $ 
    treatment $ 10.
    replicate $
    mean
    symbol_definition
  ;

  datalines;
  1 TreatmentX A 0.246 1
  1 TreatmentX B 0.479 2
  1 TreatmentX C 0.134 3
  1 TreatmentX D 0.778 4
  2 TreatmentY A 0.243 1
  2 TreatmentY B 0.763 2
  2 TreatmentY C 0.445 3
  2 TreatmentY D 0.211 4
  3 TreatmentZ A 0.231 1
  3 TreatmentZ B 0.915 2
  3 TreatmentZ C 0.654 3
  3 TreatmentZ D 0.456 4
  4 TreatmentW A 0.124 1
  4 TreatmentW B 0.567 2
  4 TreatmentW C 0.477 3
  4 TreatmentW D 0.966 4
  5 TreatmentV A 0.435 1
  5 TreatmentV B 0.891 2
  5 TreatmentV C 0.343 3
  5 TreatmentV D 0.111 4
  ;
run;

goptions 
  reset = all 
  csymbol = black
;

symbol1
  value     = square 
  height    = 2
  interpol  = join
  line      = 1
;                  

symbol2 
  value     = triangle
  height    = 2
  interpol  = join
  line      = 1
;

symbol3
  value     = circle
  height    = 2
  interpol  = join
  line      = 1
;

symbol4
  value     = star
  height    = 2
  interpol  = join
  line      = 1
;

axis1 
  offset = (5,5)
  label  = (height = 2 'Group')
  value  = (height = 1.5)
;

axis2
  value = (height = 1.5)
  label = (height = 2 angle = 90 'Mean')
;

legend1
  frame
  cborder = black
  label   = (height = 1.5 'Replicate')
  value   = (height = 1.5 'A' 'B' 'C' 'D')
  repeat  = 1
  shape   = symbol(2, 2)
;

proc gplot data = _nodes;
  plot mean*treatment = symbol_definition / legend = legend1
                                            haxis = axis1 
                                            vaxis = axis2 
                                            ;
run;
quit;
1

There are 1 answers

0
user667489 On

I don't know any simple way of doing this with gplot, but there is an appallingly convoluted workaround:

  • Add a dummy plot statement with the same number of plot requests as your original plot, but pointing to variables with only missing values so that nothing is actually plotted.
  • Set up equivalent symbol and legend statements for the dummy plot, only without the interpol=join.
  • Remove the legend from the original plot