R Series

How to labels and title of the plot

You can easily add the main title and axis labels with arguments to the plot() function in R to enhance the quality of your graphic.

Usage

plot(x, y, main = NULL, xlab = NULL, ylab = NULL ...)

Arguments

xthe coordinates of points in the plot. Alternatively, a single plotting structure, function or any R object with a plot method can be provided.
ythe y coordinates of points in the plot, optional if x is an appropriate structure.
mainan overall title for the plot. The default is "XY plot".
ylaba title for the y-axis. The default is "Outcome".
xlaba title for the x-axis. The default is "Condition".

First we need data

Let’s create data for our plot

Here some values which we will use to make a plot.

# Create data
> x <- c(1:10)
> y <- x*x

Once, we have the values ready we can start creating our plot.

# Create a plot the data we just generated
> plot(x, y)
Default Plot

Now, as you can see it is a default plot with no title not proper x and y labels too.

Likewise, we will now add labels and titles to our plot. We need three arguments
main:
 Main plot title
xlab: x-axis label
ylab: y-axis label

Let’s add title as “y=x^2 plot” and label the axis.

> plot(x, y, main="y=x^2 plot", xlab="x axis", ylab="y axis")

Colclusion

Hence, we studied how to label axis and add titles to a plot using plot() function in R.

This brings the end of this Blog. We really appreciate your time.

Hope you liked it.

Do visit our page www.zigya.com/blog for more informative blogs on Data Science

Keep Reading! Cheers!

Zigya Academy
BEING RELEVANT

Zigya Acadmey

Share
Published by
Zigya Acadmey

Recent Posts

Understanding Standard Form of Numbers: An Explanation With Examples

Through the standard form offers different advantages in mathematical calculations and scientific notation. Firstly, it…

5 months ago

How to deal with stress and anxiety in college

Introduction Stress is a feeling caused by an external trigger that makes us frustrated, such…

6 months ago

Why is Sociology Important These Days?

Sociology is a broad discipline that examines societal issues. It looks at the meaningful patterns…

6 months ago

How to Convert Inches to mm

Some info about Inch Inches are a unique measure that persuades us that even the…

8 months ago

Antilogarithms – Definition, Methods, and Examples

You should be familiar with logarithms to understand antilogarithms in a better manner. Logarithms involve…

10 months ago

नाटककार सुरेंद्र वर्मा

यहां "नाटककार सुरेंद्र वर्मा" पुस्तक की पीडीएफ विद्यार्थी, शोधार्थी और जो इसका अभ्यास के लिए…

10 months ago