Controlling axes and legends

Besides making different plots with various layer types, one can control the axes and legends of a ggvis plot. In this recipe, we demonstrate how to set the appearance properties of both axes and legends.

Getting ready

Ensure you have installed and loaded ggvis into your R session. You also need to complete the previous steps by storing house in your R environment.

How to do it…

Please perform the following steps to control axes and legends in ggvis:

  1. First, we use the add_axis function to control the axis orientation and label of a ggvis plot:
    > house %>% ggvis(~Size, ~Price) %>% layer_points() %>% 
    +   add_axis("x", title = "Real Estate Square Feet", orient="top") %>% 
    + add_axis("y", title = "Real Estate Price", title_offset ...

Get R for Data Science Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.