Skip to content
Shane Rosanbalm edited this page May 25, 2017 · 12 revisions

Macro Basics

The simplest application of the %viridis() macro requires only one parameter: n=.

%viridis(n=4)

The result of this call will be a macro variable &viridis4 which contains a space-separated list of colors from the viridis palette.

viridis4 = cx440154 cx30688E cx35B779 cxFEE724

Grouped Data

If you're using SAS v9.4 you can use &viridis4 in the datacontrastcolors= argument of the styleattrs statement.

%viridis(n=4);

proc sgplot;
   styleattrs datacontrastcolors=(&viridis4);
   series ...
run;

viridis sgplot

If you're using an earlier version of SAS you can use &viridis4 in the colors= parameter of the %modstyle() macro. There's also a one-record-per-color dataset (work.palette) that is generated. You could use this to build a discrete attribute map.

Color Response Data

The macro can also be used for color response plots. For instance, with the colormodel= argument on the heatmap statement.

%viridis
   (n=256
   ,palette=plasma
   ,result=mycolormodel
   );

proc sgplot data=plotdata;
   heatmap x=x y=y / colormodel=(&mycolormodel);
run;

plasma sgplot

Pretty, oh so pretty!

Other Macro Options

The macro has other options such as reverse and greyscale. Check out the macro header for more details.

Clone this wiki locally