## DEV Community is a community of 637,088 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

loading...

# Ploting graph with R-programming maxwizard01 Updated on ・2 min read

#### 🔥 constructing frequency distribution with R (6)

The following is an introduction for plotting simple graphs with the R Programming Language. Each example builds on the previous one.
In statistic while trying to do analysis on data the most important way of displaying information is the use of graphs. so let's see different kind of graph we can plot with codes.

### Types of Graph

1. Line Charts
2. Bar Charts
3. [Histograms]
4. Pie Charts
5. Dotcharts
6. Misc

### Line Charts

First we'll produce a very simple graph using the values in the weight vector:

### Example:

copy the following codes

``````# Define the cars vector with 8 values
weight <- c(1, 6, 11, 14, 19, 22, 26, 33)
# Graph the weight vector with all defaults
plot(weight)
``````

Result that is just a simple way to draw a line graph. all your value will be dotted. but that is not nice enough we need to add some attribute that made up perfect graph.

### Title and Colors

Let's add a title, a line to connect the points, and some color with the following codes
Example 1.2

``````weight <- c(1, 6, 11, 14, 19, 22, 26, 33)
# Graph weight using red points overlay  by a line and use o as the dot
plot(weight, type="o", col="red",font.main=11)
# Create a title with a green, bold font
title(main="Autos", col.main="red", font.main=4)
``````

### Explanation

the `plot()` function is used to plot the graph. it can take some parameters like vector ,type and color.
Vectors: is the data will want to use to plot the graph.
type: is the kind of mark and line we want to use to specify dot on the graph. it is dot by default and can be change to whatever we want e.g "h","p","s",'S','l' and 'c'
color: this is use to give our own preference color.

can we plot two line graph in one graph?? Yeah! we can and we shall take a look at that later. read the next article.