The SAS Output Delivery System and reporting techniques

Mosaic Plot (Proc Freq) - changing tile colors

Reply
Frequent Contributor
Frequent Contributor
Posts: 109

Mosaic Plot (Proc Freq) - changing tile colors

[ Edited ]

I have created a MosaicPlot using the below code. Though, I would like to change the tile colors, say pink = light gray and blue = dark gray.

 

I can go into the images properties after copying it, but my options are horrific: black/white or gray/gray. Also I added the line of code that Rick suggested on another post but I still get the obligatory title on top (https://communities.sas.com/t5/ODS-and-Base-Reporting/Outputting-a-graph-from-PROC-FREQ/m-p/226441/h...). Dropping that would be great. Also bolding labels and increasing font would be nice. Thank you.

 

 

PROC FORMAT;
	VALUE	epab_1_fmt	1	=	"Confident"
						0	=	"Not Confident";
	VALUE	time_fmt	1	=	"0 Months"
						2	=	"3 Months"
						3	=	"6 Months"
						4	=	"12 Months";
RUN;
ODS GRAPHICS ON;
ods select MosaicPlot;
title;    /* clear the title */
%modtmplt(options=replace, template=Base.Freq.Graphics.MosaicPlot, steps=t);
PROC FREQ DATA=EPA_rev;
	TABLE (epab_1)*time / TREND MEASURES CL
          PLOTS=MosaicPlot;
	LABEL epab_1 = "EPA 1";
   	TEST SMDRC;
   	EXACT TREND / maxtime=60;
   	FORMAT	epab_1 	epab_1_fmt.;
	Format	time	time_fmt.;
RUN;
ODS GRAPHICS OFF;

 

Attachment
SAS Super FREQ
Posts: 8,719

Re: Mosaic Plot (Proc Freq) - changing tile colors

Hi: This blog describes using Graph Template Language to alter the colors of the Mosaic Plot:
http://blogs.sas.com/content/iml/2013/11/06/how-to-specify-mosaic-plot-colors-in-sas.html

For more help with GTL and/or Mosaic plots, you might want to post this question in the ODS Graphics and SAS/GRAPH forum.
cynthia
Frequent Contributor
Frequent Contributor
Posts: 109

Re: Mosaic Plot (Proc Freq) - changing tile colors

[ Edited ]

Thank you. I will examine the link and update you all on my questions.

 

Though, I have entered the world of the ODS Graphics Editior! It seems like the right place, but perhaps it only augments the graph and won't let me manipulate its current content?  Any feedback on how the Editor may help?

Frequent Contributor
Frequent Contributor
Posts: 109

Re: Mosaic Plot (Proc Freq) - changing tile colors

I just reviewed the webpage and this should definitly help (given that I can figure it out). I am gonna move on to something else until I have more time to come back to this and determine how to use all dark grays for epa_b = 1 and light gray for its complement.

 

Thanks and I will likely have follow-up questions early next week.

SAS Super FREQ
Posts: 8,719

Re: Mosaic Plot (Proc Freq) - changing tile colors

Hi:
I think of the Editor as something to be used for 1-time changes. So, for example, if you change the colors TODAY, then next month when you run the graph, on next month's data you'll have to change the colors in the Editor again. This might be OK one or 2 times, but in the long run you probably do NOT want to sign up for modifying the colors in the Editor EVERY time you run the graph.

I like to use the Editor for annotating "blips" like one month sales are very low because a flood closed the office -- you might want to put that on the graph 1 time as an annotation and that would be the kind of thing I might do in the Editor. but if I needed that annotation to be on the graph EVERY month, then I'd find another way to add the note to the graph (either ANNOTATE or an INSET box).

cynthia

If you do have GTL questions, it really would be better to post them in the ODS Graphics and SAS/GRAPH forum. That's where all the graph folks hang out.

cynthia
Frequent Contributor
Frequent Contributor
Posts: 109

Re: Mosaic Plot (Proc Freq) - changing tile colors

Below gets me closer to my desired output. I would like to increase the label's font size and attr marker (which are words) font size.

 

I am getting confused since I use layout region and most examples I see are layout overlay, and I don't know how to incoporate both.

 

proc sort data=epa_rev;
	by descending epab_13 time;
run;
proc freq data=epa_rev order=data;
tables time*epab_13/ norow cellchi2 expected stdres crosslist;
ods output CrossList=FreqList(where=(Expected>0));
run;
 
/* color by response (notice that PROC FREQ reverses Y axis) */
proc template;
  define statgraph mosaicPlotParm;
    begingraph;
      layout region;
	    MosaicPlotParm category=(time epab_13) count=Frequency /
            colorresponse=epab_13 name="mosaic" colormodel=twocoloraltramp;
		 endlayout;
    endgraph;
  end;
run;
proc sgrender data=FreqList template=mosaicPlotParm;
format time time_fmt.;
FORMAT	epab_13 	epab_1_fmt.;
LABEL epab_13 = '';
LABEL TIME = "Time (days)";
run;

P.S., I would prefer the colors to be black and white, but currently I can just save this output on the gray scale as a work around.

 

Frequent Contributor
Frequent Contributor
Posts: 109

Re: Mosaic Plot (Proc Freq) - changing tile colors

[ Edited ]

Alright, I figured out the font question. Thought if anyone has an approach to make my binary outcome group gray and light gray on the graph I would be 1 step closer to the output I had been desiring.

 

proc template;
  define statgraph mosaicPlotParm;
    begingraph;
      layout region;
	    MosaicPlotParm category=(time epab_13) count=Frequency /
            colorresponse=epab_13 name="mosaic" colormodel=twocoloraltramp
			  labelattrs=(size=12pt)
			valueattrs=(size=12pt);

			 endlayout;
    endgraph;
  end;
run;

 

Ask a Question
Discussion stats
  • 6 replies
  • 453 views
  • 1 like
  • 2 in conversation