BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
coliver32
Calcite | Level 5

Hello All,

 

I am looking to create a needle SGPLOT in SAS 9.4M3 with both of the following:

 

  1. An XAXISTABLE inside of the graphic's XAXIS area (location=inside)
  2. A transparent background for the entire graphic (as normally accomplished with the noopaque SGPLOT option)

 

My question is not whether or not this is possible (I understand there can be an SGANNO work-around).  My question is whether or not there is a simple solution that will produce an XAXISTABLE inside the XAXIS area with a transparent/noopaque background.

 

When I submit the following code, I expect that my XAXISTABLE will follow the noopaque option, but it does not.  

 

ods html;
data dateCounts;
 do date="01JAN2017"d to "31DEC2017"d by 1;
    count=floor(101*rand("uniform"));
    output;
  end;
run;

ods graphics/ border=off width=9in height=5.0625in;

proc sgplot data=dateCounts nowall noborder noopaque pad=0;
  needle x=date y=count/ lineattrs=(color=grey thickness=2);
    xaxis display=(nolabel noline noticks) valueattrs=(family=garamond color=gray size=8) interval=month ;
    yaxis display=(nolabel noline noticks) values=(0 50 100) valueattrs=(family=garamond color=gray size=8);
    refline 25 50 75 100/axis=y lineattrs=(color=white thickness=1 ) transparency=0.57;
  xaxistable count / nolabel location=inside position=bottom pad=0 valueattrs=(family=garamond color=gray size=16);
format date monyy5. count comma9.;
run;

 

Note: If I use the 'location=outside' option in the XAXISTABLE statement, the resulting background will be completely transparent, but I'd rather keep the XAXISTABLE with a 'location=inside' if it is possible to do so with a transparent background.  

 

Thank you,

 

Chad

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

Using your HTML setting and a style with a background image, I place the axis table inside the graph.  There is a trick to make the background of the axis table transparent as shown below in the code.  

 

Transparent.png

 

proc template;
  define style styles.background;
  parent=styles.htmlBlue;
  style body from body /
    watermark=on
    backgroundimage='c:\Work\4K_Images\HOT_Balloon_Only_900.png';
  end;
run;

 

ods html style=styles.background;
ods graphics/ reset border=off;
proc sgplot data=sashelp.cars nowall noborder noopaque pad=0;
  vbar type / response=mpg_city stat=mean;
  xaxistable mpg_city / stat=mean valueattrs=(size=16) location=inside positioin=bottom;
  xaxis colorbands=odd colorbandattrs=(transparency=1);
run;
ods html close;

 

This places the xaxistable inside the data area, using an "InnerMargin" on the bottom of the container.  This inner margin has an opaque background by default.  Requesting COLORBANDS on the x-axis makes the inner margin transparent.  Since I don't really want the color bands, I set them to fully transparent.  Yes, we are planning on a a "real" option to do this in next release.

 

 

View solution in original post

6 REPLIES 6
Cynthia_sas
SAS Super FREQ
Hi: This might be answered more quickly if you posted the question in the ODS Graphics and SAS/GRAPH forum.

cynthia
Jay54
Meteorite | Level 14

Using your HTML setting and a style with a background image, I place the axis table inside the graph.  There is a trick to make the background of the axis table transparent as shown below in the code.  

 

Transparent.png

 

proc template;
  define style styles.background;
  parent=styles.htmlBlue;
  style body from body /
    watermark=on
    backgroundimage='c:\Work\4K_Images\HOT_Balloon_Only_900.png';
  end;
run;

 

ods html style=styles.background;
ods graphics/ reset border=off;
proc sgplot data=sashelp.cars nowall noborder noopaque pad=0;
  vbar type / response=mpg_city stat=mean;
  xaxistable mpg_city / stat=mean valueattrs=(size=16) location=inside positioin=bottom;
  xaxis colorbands=odd colorbandattrs=(transparency=1);
run;
ods html close;

 

This places the xaxistable inside the data area, using an "InnerMargin" on the bottom of the container.  This inner margin has an opaque background by default.  Requesting COLORBANDS on the x-axis makes the inner margin transparent.  Since I don't really want the color bands, I set them to fully transparent.  Yes, we are planning on a a "real" option to do this in next release.

 

 

PeterClemmensen
Tourmaline | Level 20

Never knew about the backgroundimage attribute in proc template. Very cool @Jay54 🙂 Has this been a part of proc template for long?

 

Cynthia_sas
SAS Super FREQ
Hi:
Backgroundimage has been part of PROC TEMPLATE for ODS HTML for a long time (since SAS 8). Backgroundimage and WATERMARK have not always been supported in other destinations, but for ODS HTML, it has been available.

cynthia
Jay54
Meteorite | Level 14

Personally, I avoid placing images in the background as they distract from the data in the graph.  This was done to illustrate a coding technique.  Even simple gradients can be detrimental as group colors can look different over different background colors.  This likely falls in Tufte's "Chart Junk" category.

coliver32
Calcite | Level 5

Thank you @Jay54! - Just the type of solution I was looking for. 

 

@Cynthia_sas  next time I will make sure to file my post within the most appropriate board.

 

Chad

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 2250 views
  • 0 likes
  • 4 in conversation