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;
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.
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?
Hi Reeza,
Here is the dataset:
age_group_1 | dad_count | bctr_count | population | dad_per_100000 | bctr_per_100000 | size |
0-15 | 1580 | 241 | 691527 | 228.48 | 34.85 | 0.1 |
16-19 | 575 | 156 | 272558 | 210.96 | 57.236 | 0.1 |
20-24 | 938 | 280 | 326885 | 286.95 | 85.657 | 0.1 |
25-29 | 1004 | 293 | 317345 | 316.37 | 92.329 | 0.1 |
30-34 | 856 | 241 | 328085 | 260.91 | 73.457 | 0.1 |
35-39 | 800 | 224 | 312835 | 255.73 | 71.603 | 0.1 |
40-44 | 920 | 229 | 304587 | 302.05 | 75.184 | 0.1 |
45-49 | 1017 | 292 | 327972 | 310.09 | 89.032 | 0.1 |
50-54 | 1385 | 377 | 351517 | 394.01 | 107.249 | 0.1 |
55-59 | 1577 | 407 | 351325 | 448.87 | 115.847 | 0.1 |
60-64 | 1650 | 423 | 316552 | 521.24 | 133.627 | 0.1 |
65-69 | 1751 | 390 | 281853 | 621.25 | 138.37 | 0.1 |
70-74 | 1836 | 316 | 203061 | 904.16 | 155.618 | 0.1 |
75-79 | 2109 | 297 | 146672 | 1437.9 | 202.493 | 0.1 |
80-84 | 2802 | 365 | 106992 | 2618.89 | 341.147 | 0.1 |
85-89 | 3088 | 375 | 69643 | 4434.04 | 538.46 | 0.1 |
90+ | 3146 | 298 | 42203 | 7454.45 | 706.111 | 0.1 |
I haven't got any message in the log. Sanjay's solution was quite easy to apply.
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.
Thanks a lot Sanjay! It resolved my problem easily...
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
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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.