How to Add Horizontal Discrete Legend Below the Chart in Ggvis
In this article, we are going to see how to add horizontal discrete legend below the chart in ggvis in R Programming Language.
Add Horizontal Discrete Legend Below the Chart in Ggvis
The ggvis package in R is used for data visualization. It is also used to create interactive web graphics. It is also used to create interactive graphs and plots. It is an addition to the ggplot package. It provides the framework to build HTML graphs in the working space. The package can be downloaded and installed into the working space using the following command :
A data frame can be created using the data.frame method which takes as input a number of columns and the values stored in it. This data can be visualized using the ggvis method which computes the visual representation of the y-axis and x-axis data contained in the data frame. The ggvis method has the following syntax.
- ~y,~x- y-axis and x-axis of the data frame
- stroke- the different color values to plot different lines in ggvis
The gvisLineChart is used to plot Google Line Chart with R. On plotting the data, a window screen opens plotting the data.
Syntax: gvisLineChart(data, options = list())
- data – The data frame to be plotted
- options – The specification for the data
 "Original Data frame" > print(data_frame) group people rating 1 Geekster 10 4 2 GeeksforGeeks 12 3 3 Geekster 21 5 4 Geekster 45 7 5 GeeksforGeeks 23 2 6 GeeksforGeeks 54 8 7 Geekster 22 1 8 GeeksforGeeks 12 10 9 Geekster 32 9 10 Geekster 45 6
The data can also be plotted taking into consideration the functions. For instance, the line can be drawn for x and x^2 respectively.
 "Original Data frame" > print(data_frame) x y 1 1 1 2 2 4 3 3 9 4 4 16 5 5 25
Please Login to comment...