Creating Proportional Venn Diagrams Using Google and SAS®

advertisement
Creating Proportional Venn Diagrams
Using Google and SAS®
Hillary Kruger, RTI International, USA
Proportional Venn Diagrams
(1) What are Venn diagrams?
(2) Why use them?
(3) What are good and bad examples?
(4) How are they made in SAS® with Google?
(5) Resources and References
What is a Venn Diagram?
Why Choose a Venn Diagram?
+ Venn diagrams are an effective and
efficient way to show overlapping data
+ Universally useful across disciplines
+ Easy to understand for a variety of
audiences
+ Recent resurgence in popularity
Venn Diagrams
Some Venn diagrams are not mathematically accurate, but
are still useful - or at least entertaining
Venn Diagrams
To accurately reflect data sets, one must create diagrams
that show the true overlap in data
Venn Diagrams in SAS®
SAS® offers Venn options (like below) but they are not
proportional
Proportional Venn Diagrams in SAS®
Others have addressed this previously, using tedious code,
and produced the following results:
ALGORITHM
We here present an algorithm to create an area-proportional Venn diagram of 3 sets: A1, A2 and
A3. First, assume |A1|= a1, |A2|= a2, |A3|= a3, |A1A2|= a12, |A1A3|= a13, |A2A3|=a23 and
|A1A2A3|=a123. Without loss the generality, we further assume A1, A2 and A3 are subsets of a
population P, and with 0<=ai, aij, aijk<1 (where1<=i<j<k<=3). Based on these assumptions, we
propose the following SAS algorithm to draw a proportional Venn diagram:
a) Calculate the radius of the circle for each set: ri=sqrt[ai/(2π)], where |Ai|=ai.
b) Draw the first circle A1 with center (0, 0) and radius r1.
c) Compute the distance d12 for A1 and A2, given r1, r2 and a12=|A1A2|.
d) Draw the second circle A2 with center (d12, 0) and radius r2.
e) Estimate the distance d13 for A1 and A3, and distance d23 for A2 and A3.
f) Find the center (x3, y3) of the third circle A3. With some basic geometry knowledge, it is
easily to obtain that the center of the third circle A3 can be expressed in the algebraic
fomula as x3=( d12
2+ d13
2- d23
2)/(2d12) and y3=sqrt(d13
2-x3
2).
g) Draw the third circle A3 with center (x3, y3) and radius r3.
h) Add the legend and others as required to the diagram.
Proportional Venn Diagrams
RECAP: current options
FAIR:
Interesting; not
mathematical
GOOD:
Not visually
accurate
BETTER:
Not visually
interesting
Proportional Venn Diagrams
New Option: Google and SAS®
BEST:
Visually interesting and
mathematically
accurate; simple
implementation
Pros and Cons
SAS® Only
PROS: Mathematically accurate
CONS: Visually uninteresting; tedious code
SAS® and Google
Pros: Mathematically accurate; plethora of
visualization options; simple application
Cons: ??
A Simple Venn Diagram Using Google
Here are the basic components for Google chart calls:
http://chart.googleapis.com/chart?
cht=<chart_type> &
chd=<chart_data> &
chs=<chart_size> &...additional_parameters...
http://chart.apis.google.com/chart?
cht = v &
chd= t : 50,60,0,20,0,0,0 &
chs= 300x225 &
chco= FF6342,ADDE63 &
Venn Diagrams Using Google and SAS®
http://chart.googleapis.com/chart?
cht=<chart_type> &
chd=<chart_data> &
chs=<chart_size> &...additional_parameters...
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
type
col1
col2
col3
dat1
dat2
dat3
dat4
dat5
dat6
dat7
=
=
=
=
=
=
=
=
=
=
=
v;
FF6342;
ADDE63;
63C6DE;
35;
30;
15;
8;
5;
3;
4;
**
**
**
**
**
**
**
**
**
**
**
CHART TYPE v=venn;
A COLOR;
B COLOR;
C COLOR;
SIZE OF A;
SIZE OF B;
SIZE OF C;
A+B OVERLAP;
A+C OVERLAP;
B+C OVERLAP;
A+B+C OVERLAP;
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
lab1
lab2
lab3
widt
heig
size
lege
titl
mar1
mar2
mar3
mar4
=
=
=
=
=
=
=
=
=
=
=
=
Circle+A;
Circle+B;
Circle+C;
300;
300;
&widt.x&heig.;
t;
Venn+Diagram;
5;
5;
5;
5;
**
**
**
**
**
**
**
**
**
**
**
**
LABEL A;
LABEL B;
LABEL C;
WIDTH IN DPI;
HEIGHT IN DPI;
WIDTHxHEIGHT;
LEGEND t=top;
TITLE;
MARGIN LEFT;
MARGIN RIGHT;
MARGIN TOP;
MARGIN BOTTOM;
Venn Diagrams Using Google and SAS®
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
%let
type
col1
col2
col3
dat1
dat2
dat3
dat4
dat5
dat6
dat7
lab1
lab2
lab3
widt
heig
size
lege
titl
mar1
mar2
mar3
mar4
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
v;
** CHART TYPE v=venn;
FF6342; ** A COLOR;
ADDE63; ** B COLOR;
63C6DE; ** C COLOR;
35;
** SIZE OF A;
30;
** SIZE OF B;
15;
** SIZE OF C;
8;
** A+B OVERLAP;
5;
** A+C OVERLAP;
3;
** B+C OVERLAP;
4;
** A+B+C OVERLAP;
Circle+A;
** LABEL A;
Circle+B;
** LABEL B;
Circle+C;
** LABEL C;
300;
** WIDTH IN DPI;
300;
** HEIGHT IN DPI;
&widt.x&heig.;
** WIDTHxHEIGHT;
t;
** LEGEND t=top;
Venn+Diagram;
** TITLE;
5;
** MARGIN LEFT;
5;
** MARGIN RIGHT;
5;
** MARGIN TOP;
5;
** MARGIN BOTTOM;
References

Azimaee , Mahmoud. KML Macro: Integrating SAS ® and Google API and
Its Application in Mapping Manitoba's Health Data on Google Earth and
Google Map. SAS Global Forum 2010.

Google Chart Tools / Interactive charts (aka Visualization API) Query
Language Reference (Version 0.7). Available online:
http://code.google.com/apis/visualization/documentation/querylanguage.ht
ml#plainText

Harris, Kriss. How To Generate 2, 3 and 4 Way Venn Diagrams with Drill
Down Functionality within 4 minutes! SAS Global Forum 2008.

Li, Shiqun (Stan). Using SAS ® to Create Proportional Venn Diagrams. SAS
Global Forum 2009

Massengill, Darrell. Google Maps and SAS/Graph ®.. SAS Global Forum
2010.

Roehl, William G. Bridging the Gap between the Google Analytics API and
SAS ®. SAS Global Forum 2010.
Contact Information
Hillary Kruger
3040 E. Cornwallis Road
Cox 220
Durham, NC 27709
Phone: (919) 541-6243
E-mail: hkruger@rti.org
Download