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

Hi everyone,

 

Running a simple program to produce a bubble plot as shown below. But when I run it, the output plot shows the max events on the X axis as 20, but it puts the max value in the middle of the graph space and nothing but empty space to the right.  If I add offsetmax=0 to the xaxis definition line, then it works as I would expect.  I am not sure I understand why the default value of offsetmax stops at the mid point.  Looking at the documentation, the default value "should" have auto filled the xaxis across the full width of the graph.  Any thoughts?  

 

ods graphics on / reset=all;
ods graphics / width = 100pct height = 100pct;
title 'Total Cost by Events and $ per Event';
proc sgplot data=work.myData noautolegend;
  bubble x=events y=cost size=Total_Cost/ group=subsystem datalabel=subsystem 
    transparency=0.4 datalabelattrs=(size=9 weight=bold);
  yaxis grid ;
  xaxis grid values=(0 to 20 by 5) integer ;
run;

ods graphics off; 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

My guess is that the length of the 'subsystem' variable is large (like 80). When you use a character variable as the argument to the DATALABEL= option, the plot will leave room for the maximum length.  You can either change the length of the variable when it is created or I think you can add

 

format subsystem $10.;

 

after the PROC SGPLOT statement.

View solution in original post

4 REPLIES 4
Jay54
Meteorite | Level 14

Since setting OFFSETMAX helps, that may be a clue. Displaying data label causes the offsets to be set on all sides so the text will not be clipped.  Remove the data label and see if you get the right result.  If yes, then you do need to set the offsetmin or max to remove the excess offsets.  Or, you can use a TEXT plot to display the labels.  Text plot allows better control on offsets.

DanH_sas
SAS Super FREQ

From your program, it appears that the "event" variable to probably character, making the X axis discrete. When using bubbles with a discrete axis, the axis offsets will automatically adjust to accommodate the possibility of the largest bubble being on the end. As you found, you can override this behavior using OFFSETMIN/OFFSETMAX.

 

Hope this helps!

Dan

Rick_SAS
SAS Super FREQ

My guess is that the length of the 'subsystem' variable is large (like 80). When you use a character variable as the argument to the DATALABEL= option, the plot will leave room for the maximum length.  You can either change the length of the variable when it is created or I think you can add

 

format subsystem $10.;

 

after the PROC SGPLOT statement.

FredGIII
Quartz | Level 8

So it did turn out that it was the length of the data label that was causing the problem.  I appreciate the quick responses. 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 1494 views
  • 2 likes
  • 4 in conversation