Understanding basic syntax and grammar
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.
How to do it…
Please perform the following steps to create plots with
- 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()