Basic Plots in R
Generate quick plots such as line graphs and scatter plots with built-in functions.
Basic Plots in R is a free R Academy lesson on CoddyKit — lesson 1 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the R Academy learning path, one of 3 lessons in the course, and your progress syncs across the web and the CoddyKit app.
1
Basic Plots in R
R provides built-in functions to create various types of plots for data visualization.

2
Creating a Scatter Plot
Use the plot() function to create scatter plots in R.
plot(mtcars$mpg, mtcars$hp, main='MPG vs Horsepower', xlab='Miles per Gallon', ylab='Horsepower', col='blue')3
Creating a Line Plot
Use plot() with type='l' to create a line chart.
x <- 1:10
y <- x^2
plot(x, y, type='l', col='red', main='Line Plot of x^2', xlab='X', ylab='Y')4
Creating a Bar Chart
Use barplot() to create bar charts for categorical data.
counts <- table(mtcars$cyl)
barplot(counts, col='green', main='Car Cylinder Count', xlab='Cylinders', ylab='Frequency')5
Creating a Histogram
Use hist() to visualize the distribution of a numerical variable.
hist(mtcars$mpg, col='purple', main='Histogram of MPG', xlab='Miles per Gallon')6
Creating a Boxplot
Use boxplot() to detect outliers and summarize data distribution.
boxplot(mtcars$mpg, main='Boxplot of MPG', col='orange')7
Adding Customizations
You can modify plots by changing colors, labels, and titles.
plot(mtcars$mpg, mtcars$hp, main='MPG vs Horsepower', xlab='MPG', ylab='HP', col='blue', pch=16)8
9
Saving a Plot
Use ggsave() or png() to save plots to a file.
png('plot.png')
plot(mtcars$mpg, mtcars$hp)
dev.off()10
Summary
In this lesson, you learned:
- How to create basic plots in R.
- How to customize plots with labels, colors, and titles.
- How to save plots as image files.

Frequently asked questions
Is the “Basic Plots in R” lesson free?
Yes — the full text of “Basic Plots in R” is free to read here on the web, and the R Academy course includes 3 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the R Academy course, upgrade to CoddyKit PRO.
What will I learn in “Basic Plots in R”?
Generate quick plots such as line graphs and scatter plots with built-in functions. You practise R Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start R Academy?
No prior experience is required. R Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 3, so you can start here or from the beginning and move at your own pace.
How long does the “Basic Plots in R” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this R Academy lesson?
Yes. Every R Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Basic Plots in R
- Customization of Plots
- Saving and Exporting Graphics