While working with scatter plots,box plots and how to visualise and analyse the data,I stuck up with this question.

How can I combine two different plots where in the each plot is between different variables.

This can be done using the package gridExtra in R.

Let’s take an example.

First lets create a data frame which contains information about age,salary,experience of employees of a company.


Let’s create two different plots

q1=qplot(company$age,company$salary,geom = “boxplot”)

q2=qplot(company$experience,company$salary,geom = “point”)

and then add gridExtra package


q1 and q2 plots can be combined into a single graph with grid.arrange function.


##ncol=2 will show you the plots in two different columns


Note:You can even mention nrow if you want to show a number of plots in a specified number of rows and columns.


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s