Book Image

R Data Visualization Cookbook

Book Image

R Data Visualization Cookbook

Overview of this book

Table of Contents (17 chapters)
R Data Visualization Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Generating interactive candlestick plots


We have learned a quick and easy way to plot a candlestick. In this recipe, we will learn an easy way to generate an interactive version of the same plot. The advantage of using an interactive plot is that the audience is able to interact with the visualization and this removes the guess work. Audience can hover over the chart and the values are displayed as a tooltip.

In this visualization, whenever the opening value is less than the closing value, the candlestick is filled with blue (implying a gain). Whenever the opening value is more than the closing value, the candlestick is hollow (implying a loss).

Getting ready

We will generate an interactive candlestick plot using the googleVis package. The data for the same will be downloaded using the quantmod package.

How to do it…

We will download and load the package in R using the install.packages() and library() functions:

install.packages(c("quantmod","googleVis"))
library(quantmod)
library(googleVis)

The...