R Academy · Lesson

Basic Plots in R

Generate quick plots such as line graphs and scatter plots with built-in functions.

Lesson 1 of 310 steps

Basic Plots in R is a free R Academy lesson on CoddyKit. This is lesson 1 of 3. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the R Academy learning path, and your progress syncs across the web and the CoddyKit app. The R Academy course includes 3 lessons in total.

Getting Started with R Plots

Basic Plots in R

R provides built-in functions to create various types of plots for data visualization.

Basic Plots in R — illustration 1

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')

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')

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')

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')

Creating a Boxplot

Use boxplot() to detect outliers and summarize data distribution.

boxplot(mtcars$mpg, main='Boxplot of MPG', col='orange')

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)

Saving a Plot

Use ggsave() or png() to save plots to a file.

png('plot.png')
plot(mtcars$mpg, mtcars$hp)
dev.off()

Basic Plots Recap

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.
Basic Plots in R — illustration 10
Free to start

Learn R with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
43
Lessons
159

Frequently Asked Questions

Is the “Basic Plots in R” lesson free?

Yes — any 3 lessons of the R Academy learning path, including “Basic Plots in R”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The R Academy course includes 3 lessons in total.

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, so you can start here or from the beginning and move at your own pace. This is lesson 1 of 3.

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

  1. Basic Plots in R
  2. Customization of Plots
  3. Saving and Exporting Graphics
← Back to R Academy