Adding interactivity to a ggvis plot
One of the most attractive features of ggvis
is that it can be used to create an interactive web form. This allows the user to subset the data, or even change the visual properties of the plot, through interacting with the web form. In this recipe, we introduce how to add interactivity to a ggvis
object.
Getting ready
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 add interactivity to ggvis
:
First, make a bar plot with a drop-down menu and color options:
> house %>% + ggvis(~Status, ~Price, fill:= input_select(c("red","blue"), label="Fill Color")) %>% + layer_bars() %>% + add_axis("x", title = "Status", title_offset = 40) %>% + add_axis("y", title = "Price", title_offset = 80)
Create a size slider and a color input text...