Data visualization with googleVis exercises part 7

Table, Org Chart & Tree Map

In the seventh part of our series we are going to learn about the features of some interesting types of charts. More specifically we will talk about Table, Org Chart and Tree Map.

Read the examples below to understand the logic of what we are going to do and then test yous skills with the exercise set we prepared for you. Lets begin!

Answers to the exercises are available here.

Package

As you already know, the first thing you have to do is install and load the googleVis package with:
install.packages("googleVis")
library(googleVis)

NOTE: The charts are created locally by your browser. In case they are not displayed at once press F5 to reload the page.

Table

It is quite simple to create a Table with googleVis. We will use the “Stock” dataset.
Look at the example below to create a simple table:
TableC <- gvisTable(Stock)
plot(TableC)

Exercise 1

Create a list named “TableC” and pass to it the “Stock” dataset as a table. HINT: Use gvisTable().

Exercise 2

Plot the the table. HINT: Use plot().

Table with pages

To add pages to your table use:
options=list(page='enable')

Exercise 3

Add pages to the table you just created and plot it. HINT: Use list().

Org chart

It is quite simple to create an Org Chart with googleVis. We will use the “Regions” dataset. You can see the variables of your dataset with head().
Look at the example below to create a simple Org Chart:
OrgC <- gvisOrgChart(Regions )
plot(OrgC)

Learn more about using GoogleVis in the online course Mastering in Visualization with R programming. In this course you will learn how to:

  • Work extensively with the GoogleVis package and its functionality
  • Learn what visualizations exist for your specific use case
  • And much more

Exercise 4

Create a list named “OrgC” and pass to it the “Regions” dataset as an org chart. HINT: Use gvisOrgChart().

Exercise 5

Plot the the org chart. HINT: Use plot().

Dimensions

You can adjust the dimensions of the org chart with these options:
options=list(width=600, height=250,
size='large')

Exercise 6

Adjust the dimensions of your org chart. Set height to 300, width to 550 and size to medium and plot it.

Tree Map

It is quite simple to create a Tree Map with googleVis. We will use the “Regions” dataset.
Look at the example below to create a simple Tree Map:
TreeC <- gvisTreeMap(Regions)
plot(TreeC)

Exercise 7

Create a list named “TreeC” and pass to it the “Regions” dataset as an org chart. HINT: Use gvisTreeMap().

Exercise 8

Plot the the tree map. HINT: Use plot().

You can decide tha dependents variables of your dataset by selecting it. In the example above the dependent variable was “Val”. To choose “Fac” follow the example:
TreeC <- gvisTreeMap(Regions,
"Region", "Parent",
"Fac")
plot(TreeC)

Exercise 9

Set “Fac” as your dependent variable, plot the tree map and see the difference.

Font size

Obviously you can change the font size of your tree map simply with:
options=list(fontSize=10)

Exercise 10

Set the size of your font to 20 and plot your tree map. HINT: Use fontSize.




Data visualization with googleVis solutions part 7

Below are the solutions to these exercises on visualizations with googleVis.

####################
#                  #
#    Exercise 1    #
#                  #
####################

library(googleVis)
TableC <- gvisTable(Stock)

####################
#                  #
#    Exercise 2    #
#                  #
####################

library(googleVis)
TableC <- gvisTable(Stock)
plot(TableC)

####################
#                  #
#    Exercise 3    #
#                  #
####################

library(googleVis)
TableC <- gvisTable(Stock,
                    options=list(page='enable'))
plot(TableC)

####################
#                  #
#    Exercise 4    #
#                  #
####################

library(googleVis)
OrgC <- gvisOrgChart(Regions )

####################
#                  #
#    Exercise 5    #
#                  #
####################

library(googleVis)
OrgC <- gvisOrgChart(Regions )
plot(OrgC)

####################
#                  #
#    Exercise 6    #
#                  #
####################

library(googleVis)
OrgC <- gvisOrgChart(Regions,
                     options=list(width=550, height=300,
                                  size='medium', allowCollapse=FALSE))
plot(OrgC)

####################
#                  #
#    Exercise 7    #
#                  #
####################

library(googleVis)
TreeC <- gvisTreeMap(Regions)

####################
#                  #
#    Exercise 8    #
#                  #
####################

library(googleVis)
TreeC <- gvisTreeMap(Regions)
plot(TreeC)

####################
#                  #
#    Exercise 9    #
#                  #
####################

library(googleVis)
TreeC <- gvisTreeMap(Regions,
                     "Region", "Parent",
                    "Fac")
plot(TreeC)

####################
#                  #
#    Exercise 10   #
#                  #
####################

library(googleVis)
TreeC <- gvisTreeMap(Regions,
                     "Region", "Parent",
                    "Fac",
                    options=list(fontSize=20))
plot(TreeC)



Data Visualization with googleVis solutions part 6

Below are the solutions to these exercises on visualizations with googleVis.

####################
#                  #
#    Exercise 1    #
#                  #
####################

library(googleVis)
GeoC=gvisGeoChart(Exports)

####################
#                  #
#    Exercise 2    #
#                  #
####################

library(googleVis)
GeoC=gvisGeoChart(Exports )
plot(GeoC)

####################
#                  #
#    Exercise 3    #
#                  #
####################

library(googleVis)
GeoC=gvisGeoChart(Exports,
                  locationvar="Country",
                  colorvar="Profit")
plot(GeoC)

####################
#                  #
#    Exercise 4    #
#                  #
####################

library(googleVis)
GoogleMap <- gvisMap(Andrew )

####################
#                  #
#    Exercise 5    #
#                  #
####################

library(googleVis)
GoogleMap <- gvisMap(Andrew)
plot(GoogleMap)

####################
#                  #
#    Exercise 6    #
#                  #
####################

library(googleVis)
GoogleMap <- gvisMap(Andrew,"LatLong" )
plot(GoogleMap)

####################
#                  #
#    Exercise 7    #
#                  #
####################

library(googleVis)
GoogleMap <- gvisMap(Andrew,"LatLong","Tip" )
plot(GoogleMap)

####################
#                  #
#    Exercise 8    #
#                  #
####################

library(googleVis)
GoogleMap <- gvisMap(Andrew,"LatLong","Tip",
                     options=list(showTip=FALSE
                                  ))
plot(GoogleMap)

####################
#                  #
#    Exercise 9    #
#                  #
####################

library(googleVis)
GoogleMap <- gvisMap(Andrew,"LatLong","Tip",
                     options=list(showTip=TRUE,
                                  useMapTypeControl=TRUE
                                  ))
plot(GoogleMap)

####################
#                  #
#    Exercise 10   #
#                  #
####################

library(googleVis)
GoogleMap <- gvisMap(Andrew,"LatLong","Tip",
                     options=list(showTip=TRUE,
                                  useMapTypeControl=TRUE,
                                  mapType='terrain'
                                  ))
plot(GoogleMap)



Data Visualization with googleVis exercises part 6

Geographical Charts

In part 6 of this series we are going to see some amazing geographical charts that googleVis provides.

Read the examples below to understand the logic of what we are going to do and then test yous skills with the exercise set we prepared for you. Lets begin!

Answers to the exercises are available here.

Package

As you already know, the first thing you have to do is install and load the googleVis package with:
install.packages("googleVis")
library(googleVis)

NOTE: The charts are created locally by your browser. In case they are not displayed at once press F5 to reload the page.

Geo Chart

It is quite simple to create a Geo Chart with googleVis. We will use the “Exports” dataset. First let’s take a look at it with head(Exports). As you can see there are three variables (“Country”, “Profit”, “Online”) which we are going to use later.
Look at the example below to create a simple geo chart:
Geo=gvisGeoChart(Exports )
plot(Geo)

Exercise 1

Create a list named “GeoC” and pass to it the “Exports” dataset as a geo chart. HINT: Use gvisGeoChart().

Exercise 2

Plot the the geo chart. HINT: Use plot().

Furthermore you can add much more information in your chart by using the locationvar and colorvar options to color the countries according to the their profit. Look at the example below.
Geo=gvisGeoChart(Exports,
locationvar="Country",
colorvar="Profit")
plot(Geo)

Exercise 3

Color the countries of your geo chart according to their profit and plot it. HINT: Use locationvar and colorvar.

Google Maps

It is quite simple to create a Google Map with googleVis. We will use the “Andrew” dataset. First let’s take a look at it with head(Andrew) to see its variables. Look at the example below to create a simple google map:
GoogleMap <- gvisMap(Andrew)
plot(GoogleMap)

Exercise 4

Create a list named “GoogleMap” and pass to it the “Andrew” dataset as a google map. HINT: Use gvisMap().

Learn more about using GoogleVis in the online course Mastering in Visualization with R programming. In this course you will learn how to:

  • Work extensively with the GoogleVis package and its functionality
  • Learn what visualizations exist for your specific use case
  • And much more

Exercise 5

Plot the the google map. HINT: Use plot().

As you can see there ane no data points on it as we did not select something yet. We have to select the latitude and longtitude variables for the dataset like the example below.
GoogleMap <- gvisMap(Andrew,"LatLong" )

Exercise 6

Display the map by addind the “LatLong” variable to your list and plot it.

Exercise 7

Display the “Tip” variable on your google map just like you displayed the “LatLong” and plot it.

There are some useful options that gvisMap() provides to you that can enhance your map. Check the example below.
options=list(showTip=TRUE,
showLine=TRUE,
mapType='terrain',
useMapTypeControl=TRUE)

Exercise 8

Deactivate the Tip information from your map, plot the map and then enable it again. HINT: Use showTip.

Exercise 9

Enable useMapTypeControl and plot the map.

Exercise 10

Set the mapType by default to “terrain” and plot the map.




iPlots exercises: solutions

Below are the solutions to these iPlots exercises.

####################
#                  #
#    Exercise 1    #
#                  #
####################

install.packages("iplots")
install.packages("MASS")
library(iplots)
library(MASS)
data("Cars93")
attach(Cars93)

####################
#                  #
#    Exercise 2    #
#                  #
####################

library(iplots)
library(MASS)
data("Cars93")
attach(Cars93)
imosaic(data.frame(AirBags,Cylinders,Origin))

####################
#                  #
#    Exercise 3    #
#                  #
####################

library(iplots)
library(MASS)
data("Cars93")
attach(Cars93)
ibar(Fuel.tank.capacity)

####################
#                  #
#    Exercise 4    #
#                  #
####################

library(iplots)
library(MASS)
data("Cars93")
attach(Cars93)
ibar(Fuel.tank.capacity,isSpine=T)

####################
#                  #
#    Exercise 5    #
#                  #
####################

library(iplots)
library(MASS)
data("Cars93")
attach(Cars93)
levels(Type)

####################
#                  #
#    Exercise 6    #
#                  #
####################

library(iplots)
library(MASS)
data("Cars93")
attach(Cars93)
Type2 <- ordered(Type,
                    c("Van", "Sporty","Small", "Midsize","Large","Compact"))
levels(Type2)

####################
#                  #
#    Exercise 7    #
#                  #
####################

library(iplots)
library(MASS)
data("Cars93")
attach(Cars93)
Type2 <- ordered(Type,
                    c("Van", "Sporty","Small", "Midsize","Large","Compact"))
ibar(Type)
ibar(Type2)

####################
#                  #
#    Exercise 8    #
#                  #
####################

library(iplots)
library(MASS)
data("Cars93")
attach(Cars93)
ipcp(Cars93[c(4:8,12:15,17,19:25)])

####################
#                  #
#    Exercise 9    #
#                  #
####################

library(iplots)
library(MASS)
data("Cars93")
attach(Cars93)
ibox(Cars93[4:6])

####################
#                  #
#    Exercise 10   #
#                  #
####################

library(iplots)
library(MASS)
data("Cars93")
attach(Cars93)
ibox(Wheelbase, Cylinders)



iPlots exercises

INTRODUCTION

iPlots is a package which provides interactive statistical graphics, written in Java. You can find many interesting plots such as histograms, barcharts, scatterplots, boxplots, fluctuation diagrams, parallel coordinates plots and spineplots. The amazing part is that all of these plots support querying, linked highlighting, color brushing, and interactive changing of parameters.

Before proceeding, please follow our short tutorial.

Look at the examples given and try to understand the logic behind them. Then try to solve the exercises below using R and without looking at the answers. Then check the solutions.
to check your answers.

Exercise 1

Install and call the packages iplots and MASS in your working environment and then attach the dataset “Cars93”.

Exercise 2

Create a mosaic plot of the variables “AirBags”, “Cylinders” and “Origin” of the “Cars93” dataset. HINT: Use imosaic().

Exercise 3

Create a barchart of the variable “Fuel.tank.capacity” of the “Cars93” dataset. HINT: Use ibar().

Exercise 4

Get a spineplot of the barchart you created in Exercise 3. HINT: Use spineplot.

Exercise 5

See how the variable “Type” is ordered. HINT: Use levels().

Learn more about different visualization packages in the online course R: Complete Data Visualization Solutions. In this course you will learn how to:

  • Work extensively with different packages to visualize your data
  • Learn what visualizations exist for your specific use case
  • And much more

Exercise 6

Reverse the order of the variable “Type”, name it “Type2” and check the order of “Type2”. HINT: Use ordered() and levels().

Exercise 7

Plot the barcharts of “Type” and “Type2” and spot the difference. HINT: Use ibar().

Exercise 8

Make a Parallel Coordinate Plot for all the continuous variables of “Cars93”. HINT: Use ipcp().

Exercise 9

Make a parallel boxplot for all “price” variables. HINT: Use ibox().

Exercise 10

Split the boxplot for “Wheelbase” by number of “Cylinders”. HINT: Use ibox().




How to create visualizations with iPlots package in R

INTRODUCTION

iPlots is a package which provides interactive statistical graphics, written in Java. You can find many interesting plots such as histograms, barcharts, scatterplots, boxplots, fluctuation diagrams, parallel coordinates plots and spineplots. The amazing part is that all of these plots support querying, linked highlighting, color brushing, and interactive changing of parameters.

Furthermore, iPlots includes an API for managing plots and adding user-defined objects, such as lines or polygons to a plot.

PACKAGES & DATA

In order to use the iPlots package we have to install and call it. Moreover we need a dataset to work with. Tha dataset we chose in our case is “Cars93” which contains data from 93 Cars on Sale in the USA in 1993 and we can find it in the MASS package which of course must be installed and called too. To install and call those packages and attach the “Cars93” dataset use:

install.packages("iplots")
install.packages("MASS")
library(iplots)
library(MASS)
data("Cars93")
attach(Cars93)

You can use head(Cars93) in order to see the variables of your dataset.

PLOTS

Mosaic Plot

Some of the most important features that mosaic plots in iPlots provide are standard selection, highlighting, color brushing, reordering of variables and addition or exclusion of variables. An example of a mosaic plot with iPlots follows:

library(iplots)
library(MASS)
data("Cars93")
attach(Cars93)
imosaic(data.frame(AirBags,Cylinders,Origin))

iPlots through Model View also allows same Binsize, Fluctuation Diagram and Multiple Barchart. In order to rearrange the variables use the four arrow keys

Note that you can gain further information about your plot using -mouse-over and ctlr.

Barcharts

Barcharts in iPlots also feature Spineplots (use ctrl-s or the “View” menu to switch between the two representations). See the example below.

library(MASS)
data(Cars93)
attach(Cars93)
ibar(Cylinders)

To get a spineplot via the command line use:

ibar(Cylinders, isSpine=T)

You can reorder Bars with two ways. Firstly by using the options in the “View” menu and secondly by -dragging a bar to the position you wish.
Of course you can order the categories through R in a barchart. Look at the example below:

levels(AirBags)
[1] "Driver & Passenger" "Driver only" "None"

AirBags2 <- ordered(AirBags,
c("None", "Driver only", "Driver & Passenger"))

levels(AirBags2)
[1] "None" "Driver only" "Driver & Passenger"

ibar(AirBags)
ibar(AirBags2)

Parallel Plots

I. Parallel Coordinate Plot

A parallel coordinate plot connects all cases by lines. Look at the example below which creates a Parallel Coordinate Plot for the continuous variables “Cylinders” and “Passengers” of the “Cars93” dataset.

ipcp(Cars93[c(Cylinders, Passengers)])

Parallel Boxplot

Parallel boxplots are used to compare distributions of variables. Look how to create a parallel boxplot for all “MPG” variables of the”Cars93″ dataset

ibox(Cars93[c(7,8)])

All options can be found in the “View” menu of the plot. Note, that the scale is only displayed when all variables share the same scale!

III. Boxplot y by x

Boxplots y by x show boxplots by group. If ibox() is called with a continuous variable and a factor, a boxplot y by x is created. Look at the example to see how to split “Horsepower” by “Passengers”.
ibox(Horsepower, Passengers)

Note that a boxplot y by x always uses the same scale for all boxplots for a proper comparison.

Now, let’s move on to the first set of real exercises on the iPlots package!




Data visualization with googleVis solutions part 5

Below are the solutions to these exercises on visualizations with googleVis.

####################
#                  #
#    Exercise 1    #
#                  #
####################

library(googleVis)
CandleC <- gvisCandlestickChart(OpenClose)

####################
#                  #
#    Exercise 2    #
#                  #
####################

library(googleVis)
CandleC <- gvisCandlestickChart(OpenClose)
plot(CandleC)

####################
#                  #
#    Exercise 3    #
#                  #
####################

library(googleVis)
PieC <- gvisPieChart(CityPopularity)

####################
#                  #
#    Exercise 4    #
#                  #
####################

library(googleVis)
PieC <- gvisPieChart(CityPopularity)
plot(PieC)

####################
#                  #
#    Exercise 5    #
#                  #
####################

library(googleVis)
GaugeC <-  gvisGauge(CityPopularity)

####################
#                  #
#    Exercise 6    #
#                  #
####################

library(googleVis)
GaugeC <-  gvisGauge(CityPopularity)
plot(GaugeC)

####################
#                  #
#    Exercise 7    #
#                  #
####################

library(googleVis)
GaugeC <-  gvisGauge(CityPopularity,
                     options=list(min=0, max=900, greenFrom=600,
                                  greenTo=900, yellowFrom=300, yellowTo=600,
                                  redFrom=0, redTo=300))
plot(GaugeC)
####################
#                  #
#    Exercise 8    #
#                  #
####################

library(googleVis)
GaugeC <-  gvisGauge(CityPopularity,
                     options=list(min=0, max=900, greenFrom=600,
                                  greenTo=900, yellowFrom=300, yellowTo=600,
                                  redFrom=0, redTo=300, width=500, height=300))
plot(GaugeC)

####################
#                  #
#    Exercise 9    #
#                  #
####################

library(googleVis)
co=data.frame(country=c("US", "GB", "BR"),
              population=c(15,17,19),
              size=c(33,42,22))

IntensityC <- gvisIntensityMap(co)

####################
#                  #
#    Exercise 10   #
#                  #
####################

library(googleVis)
co=data.frame(country=c("US", "GB", "BR"),
              population=c(15,17,19),
              size=c(33,42,22))

IntensityC <- gvisIntensityMap(co)
plot(IntensityC)



Data Visualization with googleVis exercises part 5

Candlestick, Pie, Gauge, Intensity Charts

In the fifth part of our journey we will meet some special but more and more usable types of charts that googleVis provides. More specifically you will learn about the features of Candlestick, Pie, Gauge and Intensity Charts.

Read the examples below to understand the logic of what we are going to do and then test yous skills with the exercise set we prepared for you. Lets begin!

Answers to the exercises are available here.

Package & Data frame

As you already know, the first thing you have to do is install and load the googleVis package with:
install.packages("googleVis")
library(googleVis)

Secondly we will create an experimental data frame which will be used for our charts’ plotting. You can create it with:
co=data.frame(country=c("US", "GB", "BR"),
population=c(15,17,19),
size=c(33,42,22))

NOTE: The charts are created locally by your browser. In case they are not displayed at once press F5 to reload the page.

Candlestick chart

It is quite simple to create a Candlestick Chart with googleVis. We will use the “OpenClose” dataset. Look at the example below:
CandleC <- gvisCandlestickChart(OpenClose,
options=list(legend='none'))
plot(CandleC)

Exercise 1

Create a list named “CandleC” and pass to it the “OpenClose” dataset as an candlestick chart. HINT: Use gvisCandlestickChart().

Exercise 2

Plot the the candlestick chart. HINT: Use plot().

Pie chart

It is quite simple to create a Pie Chart with googleVis. We will use the “CityPopularity” dataset. Look at the example below:
PieC <- gvisPieChart(CityPopularity)
plot(PieC)

Exercise 3

Create a list named “PieC” and pass to it the “CityPopularity” dataset as a pie chart. HINT: Use gvisPieChart().

Learn more about using GoogleVis in the online course Mastering in Visualization with R programming. In this course you will learn how to:

  • Work extensively with the GoogleVis package and its functionality
  • Learn what visualizations exist for your specific use case
  • And much more

Exercise 4

Plot the the pie chart. HINT: Use plot().

Gauge

The gauge chart is not very common compared with those we saw before but can be useful under certain circumstances. We will use the “CityPopularity” dataset. Look at the example:
GaugeC <- gvisGauge(CityPopularity)
plot(GaugeC)

Exercise 5

Create a list named “GaugeC” and pass to it the “CityPopularity” dataset as a gauge chart. HINT: Use gvisGauge().

Exercise 6

Plot the the gauge. HINT: Use plot().

The gauge gives you the ability to use colours in order to separate easier each area from the other. For example:
options=list(min=0, max=1200, blueFrom=900,blueTo=1200,greenFrom=600,
greenTo=900, yellowFrom=300, yellowTo=600,
redFrom=0, redTo=300, width=400, height=300)

Exercise 7

Separate the gauge to three areas by colours of your choice, from 0 to 900 and plot it. HINT: Use list().

Exercise 8

Set width to 400 and height to 300. HINT: Use width and height.

Intensity Map

The last chart we are going to see in this part is the Intensity Map.
It is quite simple to create an Intensity Map with googleVis. We will use the experimental data frame “co” we created before. Look at the example below:
IntensityC <- gvisIntensityMap(co)
plot(IntensityC)

Exercise 9

Create a list named “IntensityC” and pass to it the “co” dataset you just created as an intenisty map. HINT: Use gvisIntensityMap().

Exercise 10

Plot the the intensity map. HINT: Use plot().




Data Visualization with googleVis exercises part 4

Adding Features to your Charts

We saw in the previous charts some basic and well-known types of charts that googleVis offers to users. Before continuing with other, more sophisticated charts in the next parts we are going to “dig a little deeper” and see some interesting features of those we already know.

Read the examples below to understand the logic of what we are going to do and then test yous skills with the exercise set we prepared for you. Lets begin!

Answers to the exercises are available here.

Package & Data frame

As you already know, the first thing you have to do is install and load the googleVis package with:
install.packages("googleVis")
library(googleVis)

Secondly we will create an experimental data frame which will be used for our charts’ plotting. You can create it with:
df=data.frame(name=c("James", "Curry", "Harden"),
Pts=c(20,23,34),
Rbs=c(13,7,9))

NOTE: The charts are created locally by your browser. In case they are not displayed at once press F5 to reload the page.

Customizing Chart

We are going to use the two-axis Line Chart we created in part 1. This is the code we used, in case you forgot it:

LineC2 <- gvisLineChart(df, "name", c("Pts","Rbs"),
options=list(
series="[{targetAxisIndex: 0},
{targetAxisIndex:1}]",
vAxes="[{title:'Pts'}, {title:'Rbs'}]"
))
plot(LineC2)

Colours

To set the color of every line we can use:
series="[{color:'green', targetAxisIndex: 0,

Exercise 1

Change the colours of your line chart to green and yellow respectively and plot the chart.

Line Width

You can determine the line width of every line with:
series="[{color:'green',targetAxisIndex: 0, lineWidth: 3},

Exercise 2

Change the line width of your lines to 3 and 6 respectively and plot the chart.

Dashed lines

You can tranform your lines to dashed with:
series="[{color:'green', targetAxisIndex: 0,
lineWidth: 1, lineDashStyle: [2, 2, 20, 2, 20, 2]},

There are many styles and colours available and you can find them here.

Learn more about using GoogleVis in the online course Mastering in Visualization with R programming. In this course you will learn how to:

  • Work extensively with the GoogleVis package and its functionality
  • Learn what visualizations exist for your specific use case
  • And much more

Exercise 3

Choose two different styles of dashed lines for every line of your chart from the link above and plot your chart.

Point Shape

With the pointShape option you can choose from a variety of shapes for your points.

We will use the scatter chart we built in part 3 to see how it works. Here is the code:
ScatterCD <- gvisScatterChart(cars,
options=list(
legend="none",
pointSize=3,lineWidth=2,
title="Cars", vAxis="{title:'speed'}",
hAxis="{title:'dist'}",
width=600, height=300))
plot(ScatterCD)

Exercise 4

Change the shape of your scatter chart’s points to ‘square’ and plot it. HINT: Use pointShape.

Exercise 5

Change the shape of your scatter chart’s points to ‘triangle’, their point size to 7 and plot it.

Edit Button

A really useful and easy feature that googleVis provides is the edit button which gives the user the ability to customize the chart in an automated way.
options=list(gvis.editor="Edit!"))

Exercise 6

Add an edit button in the scatter chart you just created. HINT: Use gvis.editor.

Chart with more options

Now let’s see how we can create a chart with many features that can enhance its appearance. We will use again the 2-axis line that we used before.
LineCD2 <- gvisLineChart(df, "name", c("Pts","Rbs"),
options=list(
series="[{color:'green',targetAxisIndex: 0, lineWidth: 3,
lineDashStyle: [14, 2, 2, 7]},
{color:'yellow',targetAxisIndex:1,lineWidth: 6,
lineDashStyle: [10, 2]}]",
vAxes="[{title:'Pts'}, {title:'Rbs'}]"
))
plot(LineCD2)

Background color

You can decide the background color of your chart with:
backgroundColor="red",

Exercise 7

Set the background color of your line chart to “lightblue” and plot it. HINT: Use backgroundColor.

Title

To give a title and decide its features you can use:
title="Title",
titleTextStyle="{color:'orange',
fontName:'Courier',
fontSize:14}",

Exercise 8

Give a title of your choise to the line chart and set its font to blue, Courier of size 16. HINT: Use titleTextStyle.

Curve Type & Legend

Another nice-looking choise that googleVis gives you is to display the lines like curves with:
curveType="function"

You can also move the legend of your chart to the bottom with:
legend="bottom"

Exercise 9

Smooth the lines of your line chart by setting the curveType option to function and move the legend to the bottom. HINT: Use curveType and legend.

Axes features

Finally you can “play” with your axes. This is an example:
vAxis="{gridlines:{color:'green', count:4}}",
hAxis="{title:'City', titleTextStyle:{color:'red'}}",
series="[{color:'yellow', targetAxisIndex: 0},
{color: 'brown',targetAxisIndex:1}]",
vAxes="[{title:'val1'}, {title:'val2'}]",

Exercise 10

Give the title “Name” to your hAxis and color it orange. Separate your vAxis with 3 red gridlines. HINT: Use titleTextStyle and gridlines