Graphics Reference
In-Depth Information
Discussion
To better convey useful information, you may want to customize the appearance of the heat map.
With this example, we'll reverse the y-axis so that it progresses from top to bottom, and we'll add
tick marks every four years along the x-axis, to correspond with each presidential term. We'll
also change the color scale using
scale_fill_gradient2()
, which lets you specify a midpoint
color and the two colors at the low and high ends (
Figure 13-13
):
p
+
geom_tile()
+
scale_x_continuous(breaks
=
seq(
1940
,
1976
, by
=
4
))
+
scale_y_reverse()
+
scale_fill_gradient2(midpoint
=
50
, mid
=
"grey70"
, limits
=
c(
0
,
100
))
Figure 13-13. A heat map with customized appearance
See Also
If you want to use a different color palette, see
Using a Manually Deined Palette for a Continu-
Creating a Three-Dimensional Scatter Plot
Problem
You want to create a three-dimensional (3D) scatter plot.
Solution
We'll use the
rgl
package, which provides an interface to the OpenGL graphics library for 3D
where the first three columns represent x, y, and zcoordinates, or pass in three vectors repres-
enting the x, y, and zcoordinates.