- Graph Represents A Function
- Graph-ruled Paper
- Graph Ratio Tables
- Graph-results-pager
- Graph-related Writing

- Plotly's R graphing library makes interactive, publication-quality graphs. Examples of how to make line plots, scatter plots, area charts, bar charts, error bars, box plots, histograms, heatmaps, subplots, multiple-axes, and 3D (WebGL based) charts.
- I have an assignment with a graph that requires an R squared value. I know how to do it, I just don't know what it means or more importantly WHY I need it. If someone could explain (in normal people language) that would be awesome:).
- A bar chart represents data in rectangular bars with length of the bar proportional to the value of the variable. R uses the function barplot to create bar charts. R can draw both vertical and Horizontal bars in the bar chart.
In this article, you’ll learn to use plot function in R. It is used to make graphs according to the type of the object passed.
This cookbook contains more than 150 recipes to help scientists, engineers, programmers, and data analysts generate high-quality graphs quickly—without having to comb through all the details of R’s graphing systems. Each recipe tackles a specific problem with a solution you can apply to your own project and includes a discussion of how and why the recipe works. In this article, we would see how to add linear regression equation and r-squared to a graph in R. It is very useful when we need to document or present our statistical results.
The most used plotting function in R programming is the
plot()

plot()
.In the simplest case, we can pass in a vector and we will get a scatter plot of magnitude vs index. But generally, we pass in two vectors and a scatter plot of these points are plotted.
For example, the command plot(c(1,2),c(3,5))
would plot the points (1,3)
and (2,5)
.
Graph Represents A Function
Here is a more concrete example where we plot a sine function form range -pi
to pi
.
Adding Titles and Labeling Axes
We can add a title to our plot with the parameter main
. Similarly, xlab
and ylab
can be used to label the x-axis and y-axis respectively.
Changing Color and Plot Type
We can see above that the plot is of circular points and black in color. This is the default color.
We can change the plot type with the argument type
. It accepts the following strings and has the given effect.
Similarly, we can define the color using col
.
Overlaying Plots Using legend() function

Calling plot()
multiple times will have the effect of plotting the current graph on the same window replacing the previous one.
Graph-ruled Paper
However, sometimes we wish to overlay the plots in order to compare the results.
This is made possible with the functions lines()
and points()
to add lines and points respectively, to the existing plot.
We have used the function legend()
to appropriately display the legend. Visit legend() function to learn more.
Also visit plot() function to learn more about different arguments plot()
function can take, and more examples.
Graph Ratio Tables
Graph-results-pager

Graph-related Writing
- PREVIOUS
R Strip Chart - NEXT
R Multiple Plots
