Data visualization with SAS programming

Is it possible to have different WALLCOLORs for each panel in a DATALATTICE?

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

Is it possible to have different WALLCOLORs for each panel in a DATALATTICE?

     Hi all-

I have a custom panel graph that I'm running in SAS 9.3 (code below)

proc template;

     define statgraph AnnotatedPanel ;

          dynamic   __BYLINE__

                    _IndVar

                    _DepVar

                    _GroupVar

                    _TitleText

                    _RowVar

                    _ColVar

                    _RowLabel

                    _ColLabel

                    _cellN

                    _cellGPct

                    _cellLPct ;

          begingraph ;

               EntryTitle _TitleText ;

               EntryTitle __BYLINE__ / textattrs = (size = GraphLabelText:fontsize) ;

               layout datalattice  rowvar    = _RowVar

                                   columnvar = _ColVar /  

                              Rows                = 6

                                                            Columns             = 5

                                                            HeaderLabelDisplay  = namevalue

                                                            Inset               = (_cellN _cellGPct _cellLPct)

                                                            InsetOpts           = (  autoalign       = (TopLeft BottomRight)

                                                                                                  border          = false

                                                                                                               opaque          = false

                                                                                                  textattrs       = (size = 8pt))   

                                                            ColumnAxisOpts      = (  label           = _ColLabel

                                                                                                              linearopts      = ( viewmin = 0))

                                                            RowAxisOpts         = (  label           = _RowLabel

                                                                                                              griddisplay     = on

                                                                                                              display         = (label ticks tickvalues)) ;

                    layout prototype / wallcolor = lightgrey ;

                         SeriesPlot     X = _IndVar

                                        Y = _DepVar    /    group     = _GroupVar lineattrs = (color = red) datatransparency = 0.6 ;

                    endLayout ;

               endlayout ;

          endgraph ;

     end ;

run ;


The INSET allows me to include the N represented in each panel, as well as the percent that that represents of the overall total sample.

One thing I'd like to be able to do is specify the WALLCOLOR of each panel to correspond to the relative sample volume. For example, maybe panels will less than 1% are white, and between 1 and 5% they're light gray, and 5-10% are medium gray, and over 10% are dark gray. Basically, I want the panels to represent a macro heat map under the series plots.

Is this even possible?


Accepted Solutions
Solution
‎02-22-2014 05:14 PM
SAS Super FREQ
Posts: 1,044

Re: Is it possible to have different WALLCOLORs for each panel in a DATALATTICE?


All Replies
SAS Super FREQ
Posts: 1,044

Re: Is it possible to have different WALLCOLORs for each panel in a DATALATTICE?

While this is not supported directly, the layering architecture allows you some creative work arounds.  The simple way is to just color the scatter markers themselves by a gradient using obs count with Markercolorgradient.

GradientPanelScatter.png

To get a ramp color background, you can add a bubble plot behind the scatters.

GradientPanelBubble.png

You can also use the RangeAttrMap to control the ramp color.

In bubbleplot case, the data has only one (x,y) point per cell, so only one bubble is plotted.  Since bubble is very large ( to cover the region), you have to set the axis offsets back to a smaller value.

In both cases, the height of ramp legend is not ideal.  I'll see what we can do about that.

Sample code with made up values for obs count is attached.

Attachment
SAS Super FREQ
Posts: 1,044

Re: Is it possible to have different WALLCOLORs for each panel in a DATALATTICE?

Found a way.  Add padding to bottom of the legend.  PAD=(Bottom=58px) does the trick.

GradientPanelBubble.png

Solution
‎02-22-2014 05:14 PM
SAS Super FREQ
Posts: 1,044

Re: Is it possible to have different WALLCOLORs for each panel in a DATALATTICE?

New article on this topic in Graphically Speaking.

Contributor
Posts: 25

Re: Is it possible to have different WALLCOLORs for each panel in a DATALATTICE?

Thanks Sanjay! This worked great. It took some doing for sure, but I finally got it.

I would add, you really can't stress the importance of the offset specifications enough. Without that, the graph didn't work at all!

Post a Question
Discussion Stats
  • 4 replies
  • 441 views
  • 6 likes
  • 2 in conversation