-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
R for Data Science Cookbook (n)
By :
The ggvis uses similar grammar and syntax to ggplot2, and we can use this basic syntax to create figures. In this recipe, we cover how to use ggvis syntax and grammar to build advanced plots.
Ensure you have installed and loaded ggvis into your R session. Also, you need to complete the previous steps by storing house in your R environment.
Please perform the following steps to create plots with ggvis:
First, create a scatterplot by mapping Size to the x axis and Price to the y axis. Furthermore, we can assign different colors or shapes to points with different statuses:
> house %>% ggvis(~Size, ~Price, fill=~Status, size=10, shape=~Status) %>% layer_points()

Figure 11: A scatterplot in different shapes and colors by housing status
Also, we can use the add_props function to change the fill color to red:
> house %>% ggvis(~Size, ~Price, fill=~Status, size=10, shape=~Status) %>% layer_points() %>% add_props(fill...
Change the font size
Change margin width
Change background colour