Advanced Data Visualization in R

As data become larger ,diverse and complex we require advance version of  data visualization.

1.Data Visualization

  1. Mosaic Plot
  2. 3D Graphs
  3. Hexbin Binning

1.1 Mosaic Plot

What is Mosaic Plot? Why to choose Mosaic Plot?

A mosaic plot is a graphical display that allows you to examine the relationship among two
or more categorical variables.

If you wanted to compare the mortality rates between men and women using a mosaic plot, you would first divide the unit square according to the overall proportion of males and females.

Here in the figure below about 30% are female and 70% are male.

Next we include more adjustments.

mosaic1

Secondly now we include one more variable that depict the survival of sexes.

mosaic5

In the above diagram in females about 60% survived and in male about 25% survived.

Now the next step is to how to plot this mosaic plot

 

#Plot Mosaic Plot

data(Survivals)

mosaicplot(Survivals)

 

1.2 3D Graphs

We use  3D graphs to plot data in three dimensions.3D plots depicts the relationship between all the three variables and also shows the relationships between any of the two variables.

How to plot 3D Graphs

# Install rgl package and load library

install.packages(“rgl”)

library(rgl)

#plot 3D graph
plot3d(var1,var2,var3,xlab= “ ”,ylab= “ ”,zlab= “ ”,type= “ ”,col= “ ”,size= “ ”)

download

1.3 Hexbin Binning

Hexagon binning is a form of bivariate histogram useful for visualizing the structure in datasets with large n.

How to plot hexbins

#load library

library(hexbin)

# plot  hexbin

a=hexbin(X,Y,xbins=40)

#load color brewer

library(RColorBrewer)

#plot

plot(a)

In order to add colors for better understanding of data we use the following commands.

#load library

library(RColorBrewer)

#setting colramp

tp <- colorRampPalette(rev(brewer.pal(40,’Set3′)))

#Plot

hexbinplot(Y~X, data=burgers, colramp=tp)

download (1).png

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s