Previous > Introduction to Plotting & Applications | R Programming

Now let’s have a look at some 2-Dimensional plots:

As mentioned earlier, these plots are made with the help of R software.

## 1. BARPLOT

A bar plot is also known as a bar chart that shows bars of different values hence of different heights to depict the relationship between numerical and some sort of categorical data.

**Syntax of Bar plot in R:**

barplot(titanic$fare)

## 2. **BOXPLOT**

A simple way of representing statistical data on a plot during which a rectangle is drawn to represent the second and third quartiles, usually with a vertical line inside to point to the median. The lower and upper quartiles are shown as horizontal lines on either side of the rectangle.

**Syntax of Boxplot in R:**

boxplot(titanic$age,titanic$fare)

## 3. **SCATTERPLOT**

This plot is used to visualize the relationship between the continuous variables. Since the data points seem to be scattered in the graph hence, it is called a scatter plot. It uses cartesian coordinates to display the values.

**Syntax of Scatterplot in R:**

ggplot(titanic,aes(x = age, y = fare))+ geom_point()

## 4. **2D PIE CHART**

It is used to represent values in the form of slices of a circle in different colours. We label the slices and represent those numbers in the chart.

**Syntax of 2D Pie chart in R:**

library(plotly) fig <- plot_ly(titanic, labels =_{ ~}names, values =_{~}fare, type = 'pie') fig

## 5.** 2D DENSITY PLOT**

A related visualization to the histogram is a density plot. A density plot is a smoothed version of the histogram. It uses a kernel density estimate to point out the probability density function of the variable.

**Syntax of Density Plot in R:**

ggplot(data, aes(x=x, y=y))+ stat_density_2d(aes(fill = ..level..),geom=”polygon”)