Data visualization with SAS programming

Having Trouble with SGPlots colors

Accepted Solution Solved
Reply
Contributor
Posts: 45
Accepted Solution

Having Trouble with SGPlots colors

[ Edited ]

This is kind of related to an earlier question I had because I'm sure some of you contributors saw it. Basically I am generating a box chart and a regression plot but I want to keep the colors consistent. I am generating a lot of them and I noticed on some graphs the color would be reversed aka in the box chart red = 0, blue = 1, while in the regression plot red = 1 and blue = 0. I tried to make an ATTRMAP file but for some reason this made some of the regression colors GREEN instead of blue and I don't understand why, while in the bar chart nothing really changed.

 

 


%Macro plots(data, cholinevar, response, SNP, title);
data Attrmap;
ID = "&SNP";
Value = '0'; MarkerColor = "Blue "; output;
Value = '1'; MarkerColor = "Red "; output;
run;
PROC sGPLOT DATA = &data noautolegend dattrmap = attrmap;
vbar &cholinevar._4 / response = &response stat = mean group = &SNP groupdisplay = cluster limitstat = stderr attrid = &SNP;
title "&title";
run;
PROC sGPLOT DATA = &data noautolegend dattrmap = attrmap;
reg x = &cholinevar y = &response /group = &SNP clm attrid = &SNP;
title "&title";
run;
%mend plots;

 In the part of the macro, the issue occured with certain SNPs that I ran this through. Some of the graphs looked fine (aka consistent color between the bar chart and regression plot), but as mentioned before some of the "blue" lines turned "Green". Before I added in the dattrmap statement I had an issue with inconsistent colors.


Accepted Solutions
Solution
a month ago
SAS Super FREQ
Posts: 896

Re: Having Trouble with SGPlots colors

You haven't defined the colors for the other plot features. Try this:

 

%Macro plots(data, cholinevar, response, SNP, title);
data Attrmap;
ID = "&SNP";
Value = '0'; MarkerColor = "Blue"; FillColor="Blue"; LineColor="Blue"; output;
Value = '1'; MarkerColor = "Red"; FillColor="Red"; LineColor="Red"; output;
run;
PROC sGPLOT DATA = &data noautolegend dattrmap = attrmap;
vbar &cholinevar._4 / response = &response stat = mean group = &SNP groupdisplay = cluster limitstat = stderr attrid = &SNP;
title "&title";
run;
PROC sGPLOT DATA = &data noautolegend dattrmap = attrmap;
reg x = &cholinevar y = &response /group = &SNP clm attrid = &SNP;
title "&title";
run;
%mend plots;

View solution in original post


All Replies
SAS Super FREQ
Posts: 1,108

Re: Having Trouble with SGPlots colors

I suggest you set LineColor and FillColor in the attrmap in addition to MarkerColor.  BarCharts use the fill color, and regression lines use LineColor.

Solution
a month ago
SAS Super FREQ
Posts: 896

Re: Having Trouble with SGPlots colors

You haven't defined the colors for the other plot features. Try this:

 

%Macro plots(data, cholinevar, response, SNP, title);
data Attrmap;
ID = "&SNP";
Value = '0'; MarkerColor = "Blue"; FillColor="Blue"; LineColor="Blue"; output;
Value = '1'; MarkerColor = "Red"; FillColor="Red"; LineColor="Red"; output;
run;
PROC sGPLOT DATA = &data noautolegend dattrmap = attrmap;
vbar &cholinevar._4 / response = &response stat = mean group = &SNP groupdisplay = cluster limitstat = stderr attrid = &SNP;
title "&title";
run;
PROC sGPLOT DATA = &data noautolegend dattrmap = attrmap;
reg x = &cholinevar y = &response /group = &SNP clm attrid = &SNP;
title "&title";
run;
%mend plots;
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 211 views
  • 0 likes
  • 3 in conversation