Data visualization with SAS programming

Changing the size of the bubbles in SGPLOT

Accepted Solution Solved
Reply
Contributor
Posts: 31
Accepted Solution

Changing the size of the bubbles in SGPLOT

Hello there,

 

Can anyone help with changing the size of the bubbles in SGPLOT? The bubbles in my graph below are not proportional to the size of each cell. I would like to make them smaller than how they look in the graph. In the preceeding data step I tried to change the value of the "size" variable but it did not seem to help.

 

Thanks a lot in advance!

 

Recep

 

data _009;
merge _007 _008 rprt1516.bc_population_estimates_by_age;
by age_group_1;
dad_per_100000=100000*dad_count/population;
bctr_per_100000=100000*bctr_count/population;

size=0.1;

run;

 

proc sgplot data=_009;
bubble x=age_group_1 y=dad_count size=size / LEGENDLABEL= "All hospitalizations"
                                                                             FILLATTRS=(color=red transparency=0.6);
bubble x=age_group_1 y=bctr_count size=size / LEGENDLABEL= "BCTR hospitalizations (ISS>=9 or died)"
                                                                             FILLATTRS=(color=blue transparency=0.6);

xaxis display=all label='Age group' fitpolicy=rotate;
yaxis label='Total cases' offsetmin=.17;
run;

 

SGPlot15.png

 


Accepted Solutions
Solution
‎04-06-2017 04:13 PM
SAS Super FREQ
Posts: 1,080

Re: Changing the size of the bubbles in SGPLOT

For Bubble plot, size=column uses the BRADIUSMIN and BRADIUSMAX to map the values from the column.  If the column has only one value, all bubbles will be of the size specified by BRADIUSMIN.  So, in this case you can set the BRADIUSMIN and BRADIUSMAX values to what you want.  Please see product documentation.  

View solution in original post


All Replies
Grand Advisor
Posts: 17,325

Re: Changing the size of the bubbles in SGPLOT

Can you post an example that references a SASHELP dataset so we can replicate the issue.

 

It should be the SIZE that controls the size. 

Was there any messages in the log?

Contributor
Posts: 31

Re: Changing the size of the bubbles in SGPLOT

Hi Reeza,

 

Here is the dataset:

 

age_group_1dad_countbctr_countpopulationdad_per_100000bctr_per_100000size
0-151580241691527228.4834.850.1
16-19575156272558210.9657.2360.1
20-24938280326885286.9585.6570.1
25-291004293317345316.3792.3290.1
30-34856241328085260.9173.4570.1
35-39800224312835255.7371.6030.1
40-44920229304587302.0575.1840.1
45-491017292327972310.0989.0320.1
50-541385377351517394.01107.2490.1
55-591577407351325448.87115.8470.1
60-641650423316552521.24133.6270.1
65-691751390281853621.25138.370.1
70-741836316203061904.16155.6180.1
75-7921092971466721437.9202.4930.1
80-8428023651069922618.89341.1470.1
85-893088375696434434.04538.460.1
90+3146298422037454.45706.1110.1

 

I haven't got any message in the log. Sanjay's solution was quite easy to apply.

Solution
‎04-06-2017 04:13 PM
SAS Super FREQ
Posts: 1,080

Re: Changing the size of the bubbles in SGPLOT

For Bubble plot, size=column uses the BRADIUSMIN and BRADIUSMAX to map the values from the column.  If the column has only one value, all bubbles will be of the size specified by BRADIUSMIN.  So, in this case you can set the BRADIUSMIN and BRADIUSMAX values to what you want.  Please see product documentation.  

Contributor
Posts: 31

Re: Changing the size of the bubbles in SGPLOT

Thanks a lot Sanjay! It resolved my problem easily...

SAS Super FREQ
Posts: 889

Re: Changing the size of the bubbles in SGPLOT

Based on your data step, it appears that you are trying to create bubbles of a constant size. The intent of a BUBBLE plot is to have varying sized bubbles to reflect the changes in a third variable. I think what you might want is a SCATTER plot with CIRCLEFILLED markers. Something like this:

 

proc sgplot data=sashelp.class;
scatter x=weight y=height / markerattrs=(symbol=circlefilled size=21px) 
           filledoutlinedmarkers group=sex;
run;

 

Hope this helps!

Dan

Contributor
Posts: 31

Re: Changing the size of the bubbles in SGPLOT

Thanks a lot for your response Dan! Sanjay's solution resolved my problem. Though I'll try to use the scatter option instead of bubbles as I believe there are a bit more flexibility with the scatter.

 

Cheers,

 

Recep

☑ This topic is SOLVED.

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

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