Professional Documents
Culture Documents
Lecture5.1 Data Visualization
Lecture5.1 Data Visualization
Qing He
University at Buffalo
1
11/1/17
1 0 /1 6
2
11/1/17
References
Edward Tufte (2006). Beautiful Evidence, Graphics Press LLC. www.edwardtufte.com
3
11/1/17
4
11/1/17
Histogram Histogram
hist(pollution$pm25,
hist(pollution$pm25, col = "green")
col = "green")
rug(pollution$pm25)
1 0 /2 3
5
11/1/17
40
0
4 6 8 10 12 14
30
is the same as
5 10 15 20 plot(pollution$latitude, pollution$pm25)
subset(pollution, region == "west")$pm25
6
11/1/17
2 0 /2 3
Summary
· Exploratory plots are "quick and dirty". Let you
summarize the data (usually graphically) and highlight
any broad features
7
11/1/17
values between 0 and 1, and returns a interplated color in number > pal(2)
between 0 and 255 (e.g. see the 'gray' function) [1] "#FF0000" "#FFFF00"
· colorRampPalette: Take a palette of colors and return a function that > pal(10)
takes integer arguments and returns a vector of colors interpolating [1] "#FF0000" "#FF1C00" "#FF3800" "#FF5500" "#FF7100"
[6] "#FF8D00" "#FFAA00" "#FFC600" "#FFE200" "#FFFF00”
the palette (like heat.colors or topo.colors)
Test a COLOR!
255 = #FF in Hex, so plot(1,1,pch=16,col="#FFFF00", cex = 20)
red = (255,0,0) = #FF0000
8
11/1/17
Sequential
RColorBrewer Package
· One package on CRAN that contains interesting/useful color palettes
· There are 3 types of palettes:
- Sequential: when data range from relatively low or unintersting values to
relatively high or interesting values
Qualitative
- Diverging: where both large low and high values are interesting
- Qualitative (or categorical): when you want to distinguish discrete chunks Diverging
of data that do not have an inherent ordering.
1 0 /1 8
> cols
[1] "#E5F5F9" "#99D8C9" "#2CA25F"
9
11/1/17
Summary
· Careful use of colors in plots/maps/etc. can make it easier
for the reader to get what you're trying to say (why make it
harder?)
10