Data visualization with SAS programming

Is it possible to series plot in sgplot to have a varying transparency?

Reply
Regular Contributor
Posts: 241

Is it possible to series plot in sgplot to have a varying transparency?

Is it possible to draw lines with different transparency levels (based on a variable)? For instance, I would like to do something like below, but I get an error because transparency= option does not take a variable. :-(



Unlike the example, I have about 400 lines to overlay and I thought varying the transparency is a way to avoid over-plotting and to emphasize series based on some measure of importance (i.e., the more "important" the series is, the lower its transparency level). Maybe I am thinking about this incorrectly. Any idea to achieve similar results will be appreciated.



  /* test data */

   %let seed = 1234;

   data one;

     do id = 1 to 4;

       trans = 0.9 + 0.02 * id;

       do day = 0 to 10;

         price = 0.2 *ranuni(&seed);

         output;

       end;

     end;

   run;

 

   ods graphics on;

   ods html;

      proc sgplot data=one;

        series x=day y=price / group=id transparency=trans;

      run;

   ods html close;
SAS Super FREQ
Posts: 889

Re: Is it possible to series plot in sgplot to have a varying transparency?

Hey Chang,

The procedure does not support variable transparency; however, I do not think you would get the result you expect anyway. With that many lines, the varying transparencies would probably be lost in accumulation effect of overlaying transparent features (some areas would get more and more opaque). Some people use this effect on scatter plots to see where points cluster in the plot or on series plots to see general trends. What are you trying to accomplish with your plot?

Thanks,
Dan
Regular Contributor
Posts: 241

Re: Is it possible to series plot in sgplot to have a varying transparency?

@Dan:H
You are right. I think I over-thought. I probably don't need variable transparency. Overlaying (a constant level of) transparent features should take care of accentuating the overall patterns, if any. Thanks.
Ask a Question
Discussion stats
  • 2 replies
  • 136 views
  • 0 likes
  • 2 in conversation