Adding subscripts to plots in R

Sometimes when drawing a plot, you will need to include a subscript. This r markdown is simple to use and once you understand how to use it you will find many uses for it. It can be useful under many circumstances when plotting a graph. When using this feature, you are not limited to single characters but could use an entire string.

Description

When using a subscript in the plotting function it has the format of plot(vector, main = expression(“Title”[ subscript])). The subscript can be a number, a character, or a string. This provides a title with a subscript when you are plotting data. This process has several uses when labeling a graph. One example would be if you have multiple graphs on the same topic, in such cases the subscript supplies a means of distinguishing otherwise identical titles. The effect that is produced is that the value in the brackets is reduced in size and drops down a little. You can do more than one subscript in the same title.

What is a SubScript (in R)? How Do We Add Them?

When using a subscript in plotting a graph, the subscript text can be any letter, number, or string. Subscripts can be intermingled with the regular text of the title along with superscripts. This makes for a wide variety of things that you can do with this property. You can have more than one subscript, and the subscript text is simply smaller and drops down a little. You simply need to place the subscript in brackets, and it will automatically produce the subscript in the title of your graph. This is a straightforward process because it divides the subscript in a natural manner.

Examples of using subscripts in R

Here are three examples of a subscript in the title of a graph. Each one shows a different aspect of the subscript process.

> x = 1:10
> x
[1] 1 2 3 4 5 6 7 8 9 10
> plot(x, main = expression(“Example”[1]))

In this example, we have a number as a subscript. This is done by placing the number in square brackets.

> x = c(2, 4, 6, 8, 10, 12, 14, 16, 18, 20)
> x
[1] 2 4 6 8 10 12 14 16 18 20
> plot(x, main = expression(“Example”[“B”]))

In this example, we use a subscript character by placing the character in square brackets.

> x = c(1, 4, 9, 16, 25, 36, 49, 64, 81, 100)
> x
[1] 1 4 9 16 25 36 49 64 81 100
> plot(x, main = expression(“Example”[“CC”]* “title”))

In this example, we have a character string as a subscript. This is done by placing the character string in square brackets. We also show how to add additional words after the subscript. In each of these examples, the subscript is denoted by square brackets.

Application of Using subscripts in R

When using a subscript in r plotting there are several applications to this ability. These subscripts can be used to show an order symbol along with other label types. Subscripts can come in real handy If you are trying to use equations as a plot title. If the vector being graphed plots out a particular equation it would make sense to use that equation as the title or part of it. These square brackets allow you to use subscripts in plotting titles under any situation where you would normally use a subscript. As a result, there is no limit to the application of these subscripts.

When you are using a subscript in r plotting, it is a simple tool to use and one with many applications for using it. You can use these square brackets in a plot title to denote an order to graphs with the same title, or they can be used in denoting equations. The applications of this feature when creating a plot title are limited only by your imagination.

Scroll to top