 # Plotting 2D Graphs | 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:

### 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.

ggplot(data, aes(x=x, y=y))+